From 13dde860104979887f966b8260f63f7a14c4296b Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Fri, 18 Feb 2022 08:47:39 -0300 Subject: [PATCH 1/2] fix: some commands should ignore workspaces Add condition so commands like `npm prefix -g` and `npm whoami -g` succeed inside a workspace. --- lib/npm.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/npm.js b/lib/npm.js index 4d22b531a4662..100c98ad423ec 100644 --- a/lib/npm.js +++ b/lib/npm.js @@ -119,7 +119,9 @@ class Npm extends EventEmitter { throw new Error('Can not use --no-workspaces and --workspace at the same time') } - const filterByWorkspaces = workspacesEnabled || workspacesFilters.length > 0 + const filterByWorkspaces = + !['prefix', 'whoami'].includes(this.command) && + (workspacesEnabled || workspacesFilters.length > 0) // normally this would go in the constructor, but our tests don't // actually use a real npm object so this.npm.config isn't always // populated. this is the compromise until we can make that a reality From 44a151892ed8887757e5ee94b43cb2d7ca8b064b Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Fri, 18 Feb 2022 10:50:38 -0300 Subject: [PATCH 2/2] Add more commands --- lib/npm.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/npm.js b/lib/npm.js index 100c98ad423ec..715ea57213347 100644 --- a/lib/npm.js +++ b/lib/npm.js @@ -120,7 +120,7 @@ class Npm extends EventEmitter { } const filterByWorkspaces = - !['prefix', 'whoami'].includes(this.command) && + !['bin', 'cache', 'completion', 'doctor', 'get', 'help', 'owner', 'prefix', 'whoami'].includes(this.command) && (workspacesEnabled || workspacesFilters.length > 0) // normally this would go in the constructor, but our tests don't // actually use a real npm object so this.npm.config isn't always