Skip to content

Commit 45fc297

Browse files
authored
fix: ignore implict workspace for some commands (#4479)
Closes #4404 Special thanks to @mshima for submitting a similar PR #4439
1 parent defe79a commit 45fc297

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+191
-2
lines changed

lib/arborist-cmd.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class ArboristCmd extends BaseCommand {
1414
'include-workspace-root',
1515
]
1616

17+
static ignoreImplicitWorkspace = false
18+
1719
async execWorkspaces (args, filters) {
1820
await this.setWorkspaces(filters)
1921
return this.exec(args)

lib/base-command.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ class BaseCommand {
2020
return this.constructor.description
2121
}
2222

23+
get ignoreImplicitWorkspace () {
24+
return this.constructor.ignoreImplicitWorkspace
25+
}
26+
2327
get usage () {
2428
let usage = `npm ${this.constructor.name}\n\n`
2529
if (this.constructor.description) {

lib/commands/access.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class Access extends BaseCommand {
2727
'otp',
2828
]
2929

30+
static ignoreImplicitWorkspace = true
31+
3032
static usage = [
3133
'public [<package>]',
3234
'restricted [<package>]',

lib/commands/adduser.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class AddUser extends BaseCommand {
1616
'scope',
1717
]
1818

19+
static ignoreImplicitWorkspace = true
20+
1921
async exec (args) {
2022
const { scope } = this.npm.flatOptions
2123
const registry = this.getRegistry(this.npm.flatOptions)

lib/commands/bin.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ class Bin extends BaseCommand {
55
static description = 'Display npm bin folder'
66
static name = 'bin'
77
static params = ['global']
8+
static ignoreImplicitWorkspace = true
89

910
async exec (args) {
1011
const b = this.npm.bin

lib/commands/birthday.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ const BaseCommand = require('../base-command.js')
22

33
class Birthday extends BaseCommand {
44
static name = 'birthday'
5+
static ignoreImplicitWorkspace = true
6+
57
async exec () {
68
this.npm.config.set('yes', true)
79
return this.npm.exec('exec', ['@npmcli/npm-birthday'])

lib/commands/bugs.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class Bugs extends BaseCommand {
99
static name = 'bugs'
1010
static usage = ['[<pkgname>]']
1111
static params = ['browser', 'registry']
12+
static ignoreImplicitWorkspace = true
1213

1314
async exec (args) {
1415
if (!args || !args.length) {

lib/commands/cache.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ class Cache extends BaseCommand {
8181
'verify',
8282
]
8383

84+
static ignoreImplicitWorkspace = true
85+
8486
async completion (opts) {
8587
const argv = opts.conf.argv.remain
8688
if (argv.length === 2) {

lib/commands/completion.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const BaseCommand = require('../base-command.js')
4747
class Completion extends BaseCommand {
4848
static description = 'Tab Completion for npm'
4949
static name = 'completion'
50+
static ignoreImplicitWorkspace = false
5051

5152
// completion for the completion command
5253
async completion (opts) {

lib/commands/config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ class Config extends BaseCommand {
6161
'long',
6262
]
6363

64+
static ignoreImplicitWorkspace = false
65+
6466
async completion (opts) {
6567
const argv = opts.conf.argv.remain
6668
if (argv[1] !== 'config') {

0 commit comments

Comments
 (0)