From 5daea80dbf3a7bb6dd0692d9de017d425aea7391 Mon Sep 17 00:00:00 2001 From: Gar Date: Wed, 24 Mar 2021 10:42:28 -0700 Subject: [PATCH] fix(progress): re-add progress bar to reify The logger was no longer in flatOptions, we pass it in explicitly now --- lib/ci.js | 11 ++++++++--- lib/dedupe.js | 1 + lib/exec.js | 12 ++++++++++-- lib/install.js | 1 + lib/link.js | 9 ++++++++- lib/prune.js | 8 +++++--- lib/uninstall.js | 11 +++++++---- lib/update.js | 1 + test/lib/update.js | 7 ++++--- 9 files changed, 45 insertions(+), 16 deletions(-) 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/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 d3f11983df918..a023015ed823a 100644 --- a/lib/install.js +++ b/lib/install.js @@ -128,6 +128,7 @@ class Install extends BaseCommand { const opts = { ...this.npm.flatOptions, + log: this.npm.log, auditLevel: null, path: where, add: args, 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/uninstall.js b/lib/uninstall.js index dfdd8ebd5a1db..79a4420d89f39 100644 --- a/lib/uninstall.js +++ b/lib/uninstall.js @@ -61,12 +61,15 @@ class Uninstall extends BaseCommand { } } - const arb = new Arborist({ ...this.npm.flatOptions, path }) - - await arb.reify({ + const opts = { ...this.npm.flatOptions, + path, + log: this.npm.log, rm: args, - }) + + } + const arb = new Arborist(opts) + await arb.reify(opts) await reifyFinish(this.npm, arb) } } diff --git a/lib/update.js b/lib/update.js index 6a87dd9ecddcf..f8cb12d267d8a 100644 --- a/lib/update.js +++ b/lib/update.js @@ -51,6 +51,7 @@ class Update extends BaseCommand { const arb = new Arborist({ ...this.npm.flatOptions, + log: this.npm.log, path: where, }) diff --git a/test/lib/update.js b/test/lib/update.js index 695218a7f69cd..780484afbeb03 100644 --- a/test/lib/update.js +++ b/test/lib/update.js @@ -10,6 +10,7 @@ const config = { const noop = () => null const npm = mockNpm({ globalDir: '', + log: noop, config, prefix: '', }) @@ -38,7 +39,7 @@ t.test('no args', t => { constructor (args) { t.deepEqual( args, - { ...npm.flatOptions, path: npm.prefix }, + { ...npm.flatOptions, path: npm.prefix, log: noop }, 'should call arborist contructor with expected args' ) } @@ -72,7 +73,7 @@ t.test('with args', t => { constructor (args) { t.deepEqual( args, - { ...npm.flatOptions, path: npm.prefix }, + { ...npm.flatOptions, path: npm.prefix, log: noop }, 'should call arborist contructor with expected args' ) } @@ -140,7 +141,7 @@ t.test('update --global', t => { const { path, ...opts } = args t.deepEqual( opts, - npm.flatOptions, + { ...npm.flatOptions, log: noop }, 'should call arborist contructor with expected options' )