diff --git a/workspaces/arborist/lib/arborist/index.js b/workspaces/arborist/lib/arborist/index.js index 091e0b46574cc..5316c9b7e3b1a 100644 --- a/workspaces/arborist/lib/arborist/index.js +++ b/workspaces/arborist/lib/arborist/index.js @@ -77,7 +77,12 @@ class Arborist extends Base { replaceRegistryHost: options.replaceRegistryHost, lockfileVersion: lockfileVersion(options.lockfileVersion), installStrategy: options.global ? 'shallow' : (options.installStrategy ? options.installStrategy : 'hoisted'), + location: options.global ? 'global' : options.location, } + // don't audit when run in a non-project location + this.options.audit = (!this.options.location || this.options.location === 'project') + && options.audit !== false + this.replaceRegistryHost = this.options.replaceRegistryHost = (!this.options.replaceRegistryHost || this.options.replaceRegistryHost === 'npmjs') ? 'registry.npmjs.org' : this.options.replaceRegistryHost diff --git a/workspaces/arborist/test/arborist/index.js b/workspaces/arborist/test/arborist/index.js index 88da04b94ffed..3b52a7ef7b237 100644 --- a/workspaces/arborist/test/arborist/index.js +++ b/workspaces/arborist/test/arborist/index.js @@ -253,3 +253,13 @@ t.test('valid global/installStrategy values', t => { t.equal(new Arborist({ installStrategy: 'hoisted' }).options.installStrategy, 'hoisted') t.end() }) + +t.test('disable audit when location is not project', t => { + t.equal(new Arborist({ location: 'global' }).options.audit, false) + t.equal(new Arborist({ location: undefined }).options.audit, true) + t.equal(new Arborist({ audit: undefined }).options.audit, true) + t.equal(new Arborist({ audit: false, location: 'project' }).options.audit, false) + t.equal(new Arborist({ global: true }).options.audit, false) + t.equal(new Arborist({ global: false }).options.audit, true) + t.end() +})