From 47640eb2c3cd9891e904e3f6bc705b6618096103 Mon Sep 17 00:00:00 2001 From: isaacs Date: Fri, 23 Oct 2020 11:15:35 -0700 Subject: update lint rules to match @npmcli/arborist --- lib/rebuild.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'lib/rebuild.js') diff --git a/lib/rebuild.js b/lib/rebuild.js index a2beecc50..076cfc699 100644 --- a/lib/rebuild.js +++ b/lib/rebuild.js @@ -17,7 +17,7 @@ const rebuild = async args => { const where = npm.flatOptions.global ? globalTop : npm.prefix const arb = new Arborist({ ...npm.flatOptions, - path: where + path: where, }) if (args.length) { @@ -25,11 +25,10 @@ const rebuild = async args => { const tree = await arb.loadActual() const filter = getFilterFn(args) await arb.rebuild({ - nodes: tree.inventory.filter(filter) + nodes: tree.inventory.filter(filter), }) - } else { + } else await arb.rebuild() - } output('rebuilt dependencies successfully') } @@ -37,14 +36,18 @@ const rebuild = async args => { const getFilterFn = args => { const specs = args.map(arg => { const spec = npa(arg) - if (spec.type === 'tag' && spec.rawSpec === '') { return spec } - if (spec.type !== 'range' && spec.type !== 'version') { throw new Error('`npm rebuild` only supports SemVer version/range specifiers') } + if (spec.type === 'tag' && spec.rawSpec === '') + return spec + if (spec.type !== 'range' && spec.type !== 'version') + throw new Error('`npm rebuild` only supports SemVer version/range specifiers') return spec }) return node => specs.some(spec => { const { version } = node.package - if (spec.name !== node.name) { return false } - if (spec.rawSpec === '' || spec.rawSpec === '*') { return true } + if (spec.name !== node.name) + return false + if (spec.rawSpec === '' || spec.rawSpec === '*') + return true return semver.satisfies(version, spec.fetchSpec) }) } -- cgit v1.2.3