diff --git a/lib/audit.js b/lib/audit.js index f990e1fa5efaa..9df2698589278 100644 --- a/lib/audit.js +++ b/lib/audit.js @@ -18,6 +18,7 @@ class Audit extends BaseCommand { /* istanbul ignore next - see test/lib/load-all-commands.js */ static get params () { return [ + 'audit-level', 'dry-run', 'force', 'json', diff --git a/lib/ci.js b/lib/ci.js index b73b3a8591114..9ae31950ef102 100644 --- a/lib/ci.js +++ b/lib/ci.js @@ -42,8 +42,14 @@ class CI extends BaseCommand { } const where = this.npm.prefix - const arb = new Arborist({ ...this.npm.flatOptions, path: where }) + const opts = { + ...this.npm.flatOptions, + path: where, + log: this.npm.log, + save: false, // npm ci should never modify the lockfile or package.json + } + const arb = new Arborist(opts) await Promise.all([ arb.loadVirtual().catch(er => { log.verbose('loadVirtual', er.stack) @@ -55,8 +61,7 @@ class CI extends BaseCommand { }), removeNodeModules(where), ]) - // npm ci should never modify the lockfile or package.json - await arb.reify({ ...this.npm.flatOptions, save: false }) + await arb.reify(opts) const ignoreScripts = this.npm.config.get('ignore-scripts') // run the same set of scripts that `npm install` runs. diff --git a/lib/config.js b/lib/config.js index d5ef6ec50a5e6..6bfde9845ce33 100644 --- a/lib/config.js +++ b/lib/config.js @@ -88,6 +88,10 @@ class Config extends BaseCommand { this.config(args).then(() => cb()).catch(cb) } + execWorkspaces (args, filters, cb) { + this.exec(args, cb) + } + async config ([action, ...args]) { this.npm.log.disableProgress() try { diff --git a/lib/dedupe.js b/lib/dedupe.js index b80a777fcc2f7..9649025739c60 100644 --- a/lib/dedupe.js +++ b/lib/dedupe.js @@ -30,6 +30,7 @@ class Dedupe extends BaseCommand { const where = this.npm.prefix const opts = { ...this.npm.flatOptions, + log: this.npm.log, path: where, dryRun, } diff --git a/lib/exec.js b/lib/exec.js index 0a61de7c1200c..5967ee4234592 100644 --- a/lib/exec.js +++ b/lib/exec.js @@ -175,7 +175,11 @@ class Exec extends BaseCommand { if (needInstall) { const installDir = this.cacheInstallDir(packages) await mkdirp(installDir) - const arb = new Arborist({ ...this.npm.flatOptions, path: installDir }) + const arb = new Arborist({ + ...this.npm.flatOptions, + log: this.npm.log, + path: installDir, + }) const tree = await arb.loadActual() // at this point, we have to ensure that we get the exact same @@ -212,7 +216,11 @@ class Exec extends BaseCommand { throw new Error('canceled') } } - await arb.reify({ ...this.npm.flatOptions, add }) + await arb.reify({ + ...this.npm.flatOptions, + log: this.npm.log, + add, + }) } pathArr.unshift(resolve(installDir, 'node_modules/.bin')) } diff --git a/lib/install.js b/lib/install.js index 54ea6d8251051..a023015ed823a 100644 --- a/lib/install.js +++ b/lib/install.js @@ -126,15 +126,16 @@ class Install extends BaseCommand { if (this.npm.config.get('dev')) log.warn('install', 'Usage of the `--dev` option is deprecated. Use `--include=dev` instead.') - const arb = new Arborist({ + const opts = { ...this.npm.flatOptions, + log: this.npm.log, + auditLevel: null, path: where, - }) - - await arb.reify({ - ...this.npm.flatOptions, add: args, - }) + } + const arb = new Arborist(opts) + await arb.reify(opts) + if (!args.length && !isGlobalInstall && !ignoreScripts) { const scriptShell = this.npm.config.get('script-shell') || undefined const scripts = [ diff --git a/lib/link.js b/lib/link.js index fe9cfd3a6b254..3e9ec1807fca1 100644 --- a/lib/link.js +++ b/lib/link.js @@ -66,6 +66,7 @@ class Link extends BaseCommand { const globalOpts = { ...this.npm.flatOptions, path: globalTop, + log: this.npm.log, global: true, prune: false, } @@ -113,12 +114,14 @@ class Link extends BaseCommand { // reify all the pending names as symlinks there const localArb = new Arborist({ ...this.npm.flatOptions, + log: this.npm.log, path: this.npm.prefix, save, }) await localArb.reify({ ...this.npm.flatOptions, path: this.npm.prefix, + log: this.npm.log, add: names.map(l => `file:${resolve(globalTop, 'node_modules', l)}`), save, }) @@ -131,9 +134,13 @@ class Link extends BaseCommand { const arb = new Arborist({ ...this.npm.flatOptions, path: globalTop, + log: this.npm.log, global: true, }) - await arb.reify({ add: [`file:${this.npm.prefix}`] }) + await arb.reify({ + add: [`file:${this.npm.prefix}`], + log: this.npm.log, + }) await reifyFinish(this.npm, arb) } diff --git a/lib/prune.js b/lib/prune.js index 1da86a3e82187..5c4a549d4d7ad 100644 --- a/lib/prune.js +++ b/lib/prune.js @@ -30,11 +30,13 @@ class Prune extends BaseCommand { async prune () { const where = this.npm.prefix - const arb = new Arborist({ + const opts = { ...this.npm.flatOptions, path: where, - }) - await arb.prune(this.npm.flatOptions) + log: this.npm.log, + } + const arb = new Arborist(opts) + await arb.prune(opts) await reifyFinish(this.npm, arb) } } diff --git a/lib/set-script.js b/lib/set-script.js index df101a0acb709..9d4aadad558fb 100644 --- a/lib/set-script.js +++ b/lib/set-script.js @@ -2,6 +2,7 @@ const log = require('npmlog') const fs = require('fs') const parseJSON = require('json-parse-even-better-errors') const rpj = require('read-package-json-fast') +const { resolve } = require('path') const BaseCommand = require('./base-command.js') class SetScript extends BaseCommand { @@ -20,6 +21,16 @@ class SetScript extends BaseCommand { return ['[