Skip to content

Commit

Permalink
fix(install): ignore auditLevel
Browse files Browse the repository at this point in the history
`npm install` should not be affected by the `auditLevel` config, as the
results of audit do not change its exit status.

PR-URL: #2929
Credit: @wraithgar
Close: #2929
Reviewed-by: @ljharb, @ruyadorno
  • Loading branch information
wraithgar committed Mar 24, 2021
1 parent c0b392c commit 0379eab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
12 changes: 6 additions & 6 deletions lib/install.js
Expand Up @@ -126,15 +126,15 @@ 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,
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 = [
Expand Down
6 changes: 4 additions & 2 deletions test/lib/install.js
Expand Up @@ -32,7 +32,7 @@ test('should install using Arborist', (t) => {

const npm = mockNpm({
config: { dev: true },
flatOptions: { global: false },
flatOptions: { global: false, auditLevel: 'low' },
globalDir: 'path/to/node_modules/',
prefix: 'foo',
})
Expand All @@ -42,7 +42,9 @@ test('should install using Arborist', (t) => {
install.exec(['fizzbuzz'], er => {
if (er)
throw er
t.match(ARB_ARGS, { global: false, path: 'foo' })
t.match(ARB_ARGS,
{ global: false, path: 'foo', auditLevel: null },
'Arborist gets correct args and ignores auditLevel')
t.equal(REIFY_CALLED, true, 'called reify')
t.strictSame(SCRIPTS, [], 'no scripts when adding dep')
t.end()
Expand Down

0 comments on commit 0379eab

Please sign in to comment.