Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add missing scope on flat options #4073

Closed
wants to merge 2 commits into from
Closed
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
6 changes: 0 additions & 6 deletions lib/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ const which = require('which')
const deref = require('./utils/deref-command.js')
const setupLog = require('./utils/setup-log.js')
const cleanUpLogFiles = require('./utils/cleanup-log-files.js')
const getProjectScope = require('./utils/get-project-scope.js')

let warnedNonDashArg = false
const _runCmd = Symbol('_runCmd')
Expand Down Expand Up @@ -247,11 +246,6 @@ const npm = module.exports = new class extends EventEmitter {
if (configScope && !/^@/.test(configScope))
this.config.set('scope', `@${configScope}`, this.config.find('scope'))
process.emit('timeEnd', 'npm:load:configScope')

process.emit('time', 'npm:load:projectScope')
this.projectScope = this.config.get('scope') ||
getProjectScope(this.prefix)
process.emit('timeEnd', 'npm:load:projectScope')
}

get flatOptions () {
Expand Down
5 changes: 4 additions & 1 deletion lib/utils/config/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1716,7 +1716,10 @@ define('scope', {
`,
flatten (key, obj, flatOptions) {
const value = obj[key]
flatOptions.projectScope = value && !/^@/.test(value) ? `@${value}` : value
const scope = value && !/^@/.test(value) ? `@${value}` : value
flatOptions.scope = scope
// projectScope is kept for compatibility with npm-registry-fetch
flatOptions.projectScope = scope
},
})

Expand Down
17 changes: 0 additions & 17 deletions lib/utils/get-project-scope.js

This file was deleted.

6 changes: 3 additions & 3 deletions test/lib/utils/config/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,15 +487,15 @@ t.test('maxSockets', t => {
t.end()
})

t.test('projectScope', t => {
t.test('scope', t => {
const obj = { scope: 'asdf' }
const flat = {}
definitions.scope.flatten('scope', obj, flat)
t.strictSame(flat, { projectScope: '@asdf' }, 'prepend @ if needed')
t.strictSame(flat, { scope: '@asdf', projectScope: '@asdf' }, 'prepend @ if needed')

obj.scope = '@asdf'
definitions.scope.flatten('scope', obj, flat)
t.strictSame(flat, { projectScope: '@asdf' }, 'leave untouched if has @')
t.strictSame(flat, { scope: '@asdf', projectScope: '@asdf' }, 'leave untouched if has @')

t.end()
})
Expand Down
48 changes: 0 additions & 48 deletions test/lib/utils/get-project-scope.js

This file was deleted.