Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions workspaces/arborist/lib/arborist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions workspaces/arborist/test/arborist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})