Skip to content

Commit 7b45e9d

Browse files
committed
fix: npm config warn on workspaces
When a workspace/workspaces config option is defined, we should log a warning message to be explicit about not supporting workspaces in the context of the `npm config` command. PR-URL: #2950 Credit: @ruyadorno Close: #2950 Reviewed-by: @wraithgar
1 parent e544f8c commit 7b45e9d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/config.js

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ class Config extends BaseCommand {
8989
}
9090

9191
execWorkspaces (args, filters, cb) {
92+
this.npm.log.warn('config', 'This command does not support workspaces.')
9293
this.exec(args, cb)
9394
}
9495

test/lib/config.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const cliConfig = {
5454

5555
const npm = {
5656
log: {
57+
warn: () => null,
5758
info: () => null,
5859
enableProgress: () => null,
5960
disableProgress: () => null,
@@ -94,8 +95,17 @@ t.test('config no args', t => {
9495
})
9596

9697
t.test('config ignores workspaces', t => {
98+
npm.log.warn = (title, msg) => {
99+
t.equal(title, 'config', 'should warn with expected title')
100+
t.equal(
101+
msg,
102+
'This command does not support workspaces.',
103+
'should warn with unsupported option msg'
104+
)
105+
}
97106
config.execWorkspaces([], [], (err) => {
98107
t.match(err, /usage instructions/, 'should not error out when workspaces are defined')
108+
npm.log.warn = () => null
99109
t.end()
100110
})
101111
})
@@ -396,7 +406,7 @@ t.test('config set invalid key', t => {
396406
npm.config.validate = npmConfigValidate
397407
delete npm.config.save
398408
delete npm.config.set
399-
delete npm.log.warn
409+
npm.log.warn = () => null
400410
})
401411

402412
config.exec(['set', 'foo', 'bar'], (err) => {

0 commit comments

Comments
 (0)