diff --git a/lib/which.js b/lib/which.js index a2f690e..dc2a1ad 100644 --- a/lib/which.js +++ b/lib/which.js @@ -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) { diff --git a/test/clone.js b/test/clone.js index 2985fb1..e1cd26b 100644 --- a/test/clone.js +++ b/test/clone.js @@ -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 => { @@ -201,7 +201,7 @@ 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) @@ -209,14 +209,11 @@ t.test('again, with a submodule', t => { 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') })) })) })) diff --git a/test/revs.js b/test/revs.js index 46b25d1..4e14e6e 100644 --- a/test/revs.js +++ b/test/revs.js @@ -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}`))) +}) diff --git a/test/spawn.js b/test/spawn.js index 4a8a655..57a4ca3 100644 --- a/test/spawn.js +++ b/test/spawn.js @@ -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() })