Skip to content

Commit

Permalink
fix(progress): re-add progress bar to reify
Browse files Browse the repository at this point in the history
The logger was no longer in flatOptions, we pass it in explicitly now

PR-URL: #2944
Credit: @wraithgar
Close: #2944
Reviewed-by: @nlf
  • Loading branch information
wraithgar committed Mar 24, 2021
1 parent e8d2adc commit aba2bc6
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 16 deletions.
11 changes: 8 additions & 3 deletions lib/ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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.
Expand Down
1 change: 1 addition & 0 deletions lib/dedupe.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
12 changes: 10 additions & 2 deletions lib/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'))
}
Expand Down
1 change: 1 addition & 0 deletions lib/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class Install extends BaseCommand {

const opts = {
...this.npm.flatOptions,
log: this.npm.log,
auditLevel: null,
path: where,
add: args,
Expand Down
9 changes: 8 additions & 1 deletion lib/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class Link extends BaseCommand {
const globalOpts = {
...this.npm.flatOptions,
path: globalTop,
log: this.npm.log,
global: true,
prune: false,
}
Expand Down Expand Up @@ -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,
})
Expand All @@ -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)
}

Expand Down
8 changes: 5 additions & 3 deletions lib/prune.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
11 changes: 7 additions & 4 deletions lib/uninstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
1 change: 1 addition & 0 deletions lib/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class Update extends BaseCommand {

const arb = new Arborist({
...this.npm.flatOptions,
log: this.npm.log,
path: where,
})

Expand Down
7 changes: 4 additions & 3 deletions test/lib/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const config = {
const noop = () => null
const npm = mockNpm({
globalDir: '',
log: noop,
config,
prefix: '',
})
Expand Down Expand Up @@ -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'
)
}
Expand Down Expand Up @@ -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'
)
}
Expand Down Expand Up @@ -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'
)

Expand Down

0 comments on commit aba2bc6

Please sign in to comment.