Skip to content

Commit

Permalink
fix: linting
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithgar committed Aug 15, 2022
1 parent 6084a91 commit ea31a17
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 35 deletions.
4 changes: 3 additions & 1 deletion lib/which.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ const which = require('which')
let gitPath
try {
gitPath = which.sync('git')
} catch (e) {}
} catch {
// ignore errors
}

module.exports = (opts = {}) => {
if (opts.git) {
Expand Down
17 changes: 7 additions & 10 deletions test/clone.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ t.test('check every out', t => {
}))
})

t.test('again, with a submodule', t => {
t.test('again, with a submodule', async t => {
t.jobs = 2
t.plan(platforms.length)
platforms.forEach(fakePlatform => t.test(`platform=${fakePlatform}`, t => {
Expand All @@ -201,22 +201,19 @@ t.test('again, with a submodule', t => {
shallows.forEach(gitShallow => t.test(`shallow=${gitShallow}`, t => {
t.jobs = 2
t.plan(refs.length + 1)
refs.concat(submodsRepoSha).forEach(ref => t.test(`ref=${ref}`, t => {
refs.concat(submodsRepoSha).forEach(ref => t.test(`ref=${ref}`, async t => {
const safeRef = `${ref}`.replace(/[^a-z0-9.]/g, '-')
const name = `withsub-${fakePlatform}-${gitShallow}-${safeRef}`
const cwd = resolve(me, name)
mkdirp.sync(cwd)
const target = resolve(cwd, 'submodule-repo')
const spec = ref === undefined ? undefined : npa(remote + (ref ? `#${ref}` : ''))
const opts = { fakePlatform, gitShallow, cwd, spec }
return clone(submodsRemote, ref, undefined, opts)
.then(sha => t.match(sha, hashre, `got a sha for ref=${ref}`))
.then(() => {
const sub = resolve(target, 'fooblz')
t.ok(fs.statSync(sub).isDirectory(), 'sub is directory')
t.equal(fs.readFileSync(sub + '/gleep', 'utf8'), 'glorp',
'gleep file is glorpy')
})
const sha = await clone(submodsRemote, ref, undefined, opts)
t.match(sha, hashre, `got a sha for ref=${ref}`)
const sub = resolve(target, 'fooblz')
t.ok(fs.statSync(sub).isDirectory(), 'sub is directory')
t.equal(fs.readFileSync(sub + '/gleep', 'utf8'), 'glorp', 'gleep file is glorpy')
}))
}))
}))
Expand Down
15 changes: 8 additions & 7 deletions test/revs.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,11 @@ const expect = {
shas: Object,
}

t.test('check the revs', t =>
revs(repo, { noGitRevCache: true }).then(r => revs(repo).then(r2 => {
t.equal(r, r2)
t.match(r, expect)
Object.keys(r.shas).forEach(sha => r.shas[sha].forEach(ref =>
t.equal(r.refs[ref].sha, sha, `shas list is consistent ${ref}`)))
})))
t.test('check the revs', async t => {
const r = await revs(repo, { noGitRevCache: true })
const r2 = await revs(repo)
t.equal(r, r2)
t.match(r, expect)
Object.keys(r.shas).forEach(sha => r.shas[sha].forEach(ref =>
t.equal(r.refs[ref].sha, sha, `shas list is consistent ${ref}`)))
})
34 changes: 17 additions & 17 deletions test/spawn.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,27 +75,27 @@ process.exit(1)
stderr: gitMessage,
message: 'A git connection error occurred',
})
Object.keys(retryOptions).forEach(n => t.test(n, t =>
t.rejects(spawn([te], {
Object.keys(retryOptions).forEach(n => t.test(n, async t => {
await t.rejects(spawn([te], {
cwd: repo,
git: process.execPath,
allowReplace: true,
...(retryOptions[n]),
}), er).then(() => {
t.same(logs, [
[
'silly',
'git',
`Retrying git command: ${te} attempt # 2`,
],
[
'silly',
'git',
`Retrying git command: ${te} attempt # 3`,
],
], 'got expected logs')
logs.length = 0
})))
}), er)
t.same(logs, [
[
'silly',
'git',
`Retrying git command: ${te} attempt # 2`,
],
[
'silly',
'git',
`Retrying git command: ${te} attempt # 3`,
],
], 'got expected logs')
logs.length = 0
}))
t.end()
})

Expand Down

0 comments on commit ea31a17

Please sign in to comment.