Skip to content

Commit ac5aa70

Browse files
ruyadornoisaacs
authored andcommitted
fix: scope config
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
1 parent ef8f567 commit ac5aa70

File tree

3 files changed

+4
-13
lines changed

3 files changed

+4
-13
lines changed

lib/utils/flat-options.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ const flatOptions = npm => npm.flatOptions || Object.freeze({
6868
npm.config.get('registry'),
6969
sendMetrics: npm.config.get('send-metrics'),
7070
registry: npm.config.get('registry'),
71-
get scope () {
72-
return npm.projectScope
73-
},
71+
scope: npm.config.get('scope'),
7472
access: npm.config.get('access'),
7573
alwaysAuth: npm.config.get('always-auth'),
7674
audit: npm.config.get('audit'),

tap-snapshots/test-lib-utils-flat-options.js-TAP.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ Object {
9696
"saveBundle": false,
9797
"savePrefix": "",
9898
"saveType": "peerOptional",
99-
"scope": "@npmcli",
99+
"scope": "",
100100
"scriptShell": "script-shell",
101101
"search": Object {
102102
"description": "description",

test/lib/utils/flat-options.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ class MockConfig {
104104
'cache-max': 'cache-max',
105105
'cache-min': 'cache-min',
106106
'strict-ssl': 'strict-ssl',
107+
scope: '',
107108
tag: 'tag',
108109
'user-agent': 'user-agent',
109110
'@scope:registry': '@scope:registry',
@@ -187,15 +188,6 @@ t.test('tag emits warning', t => {
187188
t.end()
188189
})
189190

190-
t.test('scope emits warning', t => {
191-
const npm = new Mocknpm()
192-
logs.length = 0
193-
t.equal(flatOptions(npm).scope, '@npmcli')
194-
t.match(logs, [])
195-
logs.length = 0
196-
t.end()
197-
})
198-
199191
t.test('omit/include options', t => {
200192
t.test('omit explicitly', t => {
201193
const npm = new Mocknpm({
@@ -291,6 +283,7 @@ t.test('various default values and falsey fallbacks', t => {
291283
'metricsRegistry defaults to registry')
292284
t.equal(opts.search.limit, 20, 'searchLimit defaults to 20')
293285
t.equal(opts.savePrefix, '>=', 'save-prefix respected if no save-exact')
286+
t.equal(opts.scope, '', 'scope defaults to empty string')
294287
logs.length = 0
295288
t.end()
296289
})

0 commit comments

Comments
 (0)