Skip to content

Commit c5c6d16

Browse files
yuquwraithgar
authored andcommitted
fix: add missing scope on flat options
PR-URL: #4060 Credit: @yuqu Close: #4060 Reviewed-by: @wraithgar
1 parent 5f4040a commit c5c6d16

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

lib/utils/config/definitions.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1782,7 +1782,10 @@ define('scope', {
17821782
`,
17831783
flatten (key, obj, flatOptions) {
17841784
const value = obj[key]
1785-
flatOptions.projectScope = value && !/^@/.test(value) ? `@${value}` : value
1785+
const scope = value && !/^@/.test(value) ? `@${value}` : value
1786+
flatOptions.scope = scope
1787+
// projectScope is kept for compatibility with npm-registry-fetch
1788+
flatOptions.projectScope = scope
17861789
},
17871790
})
17881791

test/lib/utils/config/definitions.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,15 +488,15 @@ t.test('maxSockets', t => {
488488
t.end()
489489
})
490490

491-
t.test('projectScope', t => {
491+
t.test('scope', t => {
492492
const obj = { scope: 'asdf' }
493493
const flat = {}
494494
definitions.scope.flatten('scope', obj, flat)
495-
t.strictSame(flat, { projectScope: '@asdf' }, 'prepend @ if needed')
495+
t.strictSame(flat, { scope: '@asdf', projectScope: '@asdf' }, 'prepend @ if needed')
496496

497497
obj.scope = '@asdf'
498498
definitions.scope.flatten('scope', obj, flat)
499-
t.strictSame(flat, { projectScope: '@asdf' }, 'leave untouched if has @')
499+
t.strictSame(flat, { scope: '@asdf', projectScope: '@asdf' }, 'leave untouched if has @')
500500

501501
t.end()
502502
})

0 commit comments

Comments
 (0)