Skip to content

Commit

Permalink
feat(arborist): do not audit outside of project locations
Browse files Browse the repository at this point in the history
BREAKING CHANGE: We no longer audit for non-project locations

Co-authored-by: Nathan Fritz <fritzy@github.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
  • Loading branch information
3 people authored and lukekarrys committed Oct 19, 2022
1 parent 46d038f commit 260afc5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
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()
})

0 comments on commit 260afc5

Please sign in to comment.