Skip to content

Commit

Permalink
fix: scope config
Browse files Browse the repository at this point in the history
The `flatOptions.scope` option should not default to `projectScope`
since that's causing projects that have a defined `projectScope`
corresponding to configured scoped registries to try and download ALL
packages (including the ones that should be downloaded from the public
registry) to be fetch from that scoped registry url.

fix #1654

PR-URL: #1758
Credit: @ruyadorno
Close: #1758
Reviewed-by: @isaacs
  • Loading branch information
ruyadorno authored and isaacs committed Sep 4, 2020
1 parent ef8f567 commit ac5aa70
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
4 changes: 1 addition & 3 deletions lib/utils/flat-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ const flatOptions = npm => npm.flatOptions || Object.freeze({
npm.config.get('registry'),
sendMetrics: npm.config.get('send-metrics'),
registry: npm.config.get('registry'),
get scope () {
return npm.projectScope
},
scope: npm.config.get('scope'),
access: npm.config.get('access'),
alwaysAuth: npm.config.get('always-auth'),
audit: npm.config.get('audit'),
Expand Down
2 changes: 1 addition & 1 deletion tap-snapshots/test-lib-utils-flat-options.js-TAP.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Object {
"saveBundle": false,
"savePrefix": "",
"saveType": "peerOptional",
"scope": "@npmcli",
"scope": "",
"scriptShell": "script-shell",
"search": Object {
"description": "description",
Expand Down
11 changes: 2 additions & 9 deletions test/lib/utils/flat-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class MockConfig {
'cache-max': 'cache-max',
'cache-min': 'cache-min',
'strict-ssl': 'strict-ssl',
scope: '',
tag: 'tag',
'user-agent': 'user-agent',
'@scope:registry': '@scope:registry',
Expand Down Expand Up @@ -187,15 +188,6 @@ t.test('tag emits warning', t => {
t.end()
})

t.test('scope emits warning', t => {
const npm = new Mocknpm()
logs.length = 0
t.equal(flatOptions(npm).scope, '@npmcli')
t.match(logs, [])
logs.length = 0
t.end()
})

t.test('omit/include options', t => {
t.test('omit explicitly', t => {
const npm = new Mocknpm({
Expand Down Expand Up @@ -291,6 +283,7 @@ t.test('various default values and falsey fallbacks', t => {
'metricsRegistry defaults to registry')
t.equal(opts.search.limit, 20, 'searchLimit defaults to 20')
t.equal(opts.savePrefix, '>=', 'save-prefix respected if no save-exact')
t.equal(opts.scope, '', 'scope defaults to empty string')
logs.length = 0
t.end()
})
Expand Down

0 comments on commit ac5aa70

Please sign in to comment.