From ad82c09ff79ee183846b85fd7a31cf35264c1b12 Mon Sep 17 00:00:00 2001 From: Nathan Fritz Date: Sat, 26 Feb 2022 17:35:46 -0800 Subject: [PATCH 1/4] fix: ignore implict workspace for some commands closes #4404 --- lib/npm.js | 30 +++++++++++++- test/lib/npm.js | 105 +++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 133 insertions(+), 2 deletions(-) diff --git a/lib/npm.js b/lib/npm.js index ce8f6aee8f575..16c19f4cc1b7a 100644 --- a/lib/npm.js +++ b/lib/npm.js @@ -24,6 +24,28 @@ const _tmpFolder = Symbol('_tmpFolder') const _title = Symbol('_title') const pkg = require('../package.json') +const ignoreWorkspacesCommands = new Set([ + 'adduser', + 'access', + 'login', + 'bin', + 'birthday', + 'bugs', + 'cache', + 'help-search', + 'help', + 'hook', + 'logout', + 'org', + // 'owner', // TODO, this may need some workspace support + 'ping', + 'prefix', + 'profile', + // 'restart', // TODO add workspace support + 'root', + 'search', +]) + class Npm extends EventEmitter { static get version () { return pkg.version @@ -113,12 +135,18 @@ class Npm extends EventEmitter { } const workspacesEnabled = this.config.get('workspaces') + /* istanbul ignore next */ + const implicitWorkspace = (this.config.get('workspace', 'default') || []).length > 0 const workspacesFilters = this.config.get('workspace') if (workspacesEnabled === false && workspacesFilters.length > 0) { throw new Error('Can not use --no-workspaces and --workspace at the same time') } - const filterByWorkspaces = workspacesEnabled || workspacesFilters.length > 0 + // only call execWorkspaces when we have workspaces explicitly set + // or when it is implicit and not in our ignore list + const filterByWorkspaces = + (workspacesEnabled || workspacesFilters.length > 0) + && (!implicitWorkspace || !ignoreWorkspacesCommands.has(cmd)) // 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 diff --git a/test/lib/npm.js b/test/lib/npm.js index 2a0c5a89d2d99..76b4aad1c6132 100644 --- a/test/lib/npm.js +++ b/test/lib/npm.js @@ -1,5 +1,5 @@ const t = require('tap') -const { resolve, dirname } = require('path') +const { resolve, dirname, join } = require('path') const { load: loadMockNpm } = require('../fixtures/mock-npm.js') const mockGlobals = require('../fixtures/mock-globals') @@ -520,3 +520,106 @@ t.test('unknown command', async t => { { code: 'EUNKNOWNCOMMAND' } ) }) + +t.test('explicit workspace rejection', async t => { + mockGlobals(t, { + 'process.argv': [ + process.execPath, + process.argv[1], + '--color', 'false', + '--workspace', './packages/a', + ], + }) + const mock = await loadMockNpm(t, { + testdir: { + packages: { + a: { + 'package.json': JSON.stringify({ + name: 'a', + version: '1.0.0', + scripts: { test: 'echo test a' }, + }), + }, + }, + 'package.json': JSON.stringify({ + name: 'root', + version: '1.0.0', + workspaces: ['./packages/a'], + }), + }, + }) + await t.rejects( + mock.npm.exec('ping', []), + /This command does not support workspaces/ + ) +}) + +t.test('implicit workspace rejection', async t => { + const mock = await loadMockNpm(t, { + testdir: { + packages: { + a: { + 'package.json': JSON.stringify({ + name: 'a', + version: '1.0.0', + scripts: { test: 'echo test a' }, + }), + }, + }, + 'package.json': JSON.stringify({ + name: 'root', + version: '1.0.0', + workspaces: ['./packages/a'], + }), + }, + }) + const cwd = join(mock.npm.config.localPrefix, 'packages', 'a') + mock.npm.config.set('workspace', [cwd], 'default') + console.log(mock.npm.config.get('workspace', 'default')) + mockGlobals(t, { + 'process.argv': [ + process.execPath, + process.argv[1], + '--color', 'false', + ], + }) + await t.rejects( + mock.npm.exec('owner', []), + /This command does not support workspaces/ + ) +}) + +t.test('implicit workspace accept', async t => { + const mock = await loadMockNpm(t, { + testdir: { + packages: { + a: { + 'package.json': JSON.stringify({ + name: 'a', + version: '1.0.0', + scripts: { test: 'echo test a' }, + }), + }, + }, + 'package.json': JSON.stringify({ + name: 'root', + version: '1.0.0', + workspaces: ['./packages/a'], + }), + }, + }) + const cwd = join(mock.npm.config.localPrefix, 'packages', 'a') + mock.npm.config.set('workspace', [cwd], 'default') + mockGlobals(t, { + 'process.cwd': () => mock.npm.config.cwd, + 'process.argv': [ + process.execPath, + process.argv[1], + '--color', 'false', + ], + }) + await t.rejects( + mock.npm.exec('org', []), + /.*Usage/ + ) +}) From 910a52c48d46aa53a422ed89a9d905db9e72592a Mon Sep 17 00:00:00 2001 From: Nathan Fritz Date: Mon, 28 Feb 2022 10:46:50 -0800 Subject: [PATCH 2/4] fix: pr feedback --- lib/base-command.js | 4 ++++ lib/commands/access.js | 2 ++ lib/commands/adduser.js | 2 ++ lib/commands/bin.js | 1 + lib/commands/birthday.js | 2 ++ lib/commands/bugs.js | 1 + lib/commands/cache.js | 2 ++ lib/commands/help-search.js | 1 + lib/commands/help.js | 1 + lib/commands/hook.js | 2 ++ lib/commands/logout.js | 2 ++ lib/commands/org.js | 1 + lib/commands/ping.js | 1 + lib/commands/prefix.js | 1 + lib/commands/profile.js | 2 ++ lib/commands/root.js | 1 + lib/commands/search.js | 1 + lib/npm.js | 24 +----------------------- test/lib/npm.js | 1 - 19 files changed, 28 insertions(+), 24 deletions(-) diff --git a/lib/base-command.js b/lib/base-command.js index f67f99f36367c..6dc29c2badc60 100644 --- a/lib/base-command.js +++ b/lib/base-command.js @@ -20,6 +20,10 @@ class BaseCommand { return this.constructor.description } + get ignoreImplicitWorkspace () { + return !!this.constructor.ignoreImplicitWorkspace + } + get usage () { let usage = `npm ${this.constructor.name}\n\n` if (this.constructor.description) { diff --git a/lib/commands/access.js b/lib/commands/access.js index 206d6de9c22c4..bc8ce48bacdad 100644 --- a/lib/commands/access.js +++ b/lib/commands/access.js @@ -27,6 +27,8 @@ class Access extends BaseCommand { 'otp', ] + static ignoreImplicitWorkspace = true + static usage = [ 'public []', 'restricted []', diff --git a/lib/commands/adduser.js b/lib/commands/adduser.js index cbeaaaf0f28be..755abea8eb9eb 100644 --- a/lib/commands/adduser.js +++ b/lib/commands/adduser.js @@ -16,6 +16,8 @@ class AddUser extends BaseCommand { 'scope', ] + static ignoreImplicitWorkspace = true + async exec (args) { const { scope } = this.npm.flatOptions const registry = this.getRegistry(this.npm.flatOptions) diff --git a/lib/commands/bin.js b/lib/commands/bin.js index bb700d45a8f1b..77028f06dd49a 100644 --- a/lib/commands/bin.js +++ b/lib/commands/bin.js @@ -5,6 +5,7 @@ class Bin extends BaseCommand { static description = 'Display npm bin folder' static name = 'bin' static params = ['global'] + static ignoreImplicitWorkspace = true async exec (args) { const b = this.npm.bin diff --git a/lib/commands/birthday.js b/lib/commands/birthday.js index 27fe2c50cab02..e889b39f25377 100644 --- a/lib/commands/birthday.js +++ b/lib/commands/birthday.js @@ -2,6 +2,8 @@ const BaseCommand = require('../base-command.js') class Birthday extends BaseCommand { static name = 'birthday' + static ignoreImplicitWorkspace = true + async exec () { this.npm.config.set('yes', true) return this.npm.exec('exec', ['@npmcli/npm-birthday']) diff --git a/lib/commands/bugs.js b/lib/commands/bugs.js index 5dfd1eb918959..f6218f033f3d3 100644 --- a/lib/commands/bugs.js +++ b/lib/commands/bugs.js @@ -9,6 +9,7 @@ class Bugs extends BaseCommand { static name = 'bugs' static usage = ['[]'] static params = ['browser', 'registry'] + static ignoreImplicitWorkspace = true async exec (args) { if (!args || !args.length) { diff --git a/lib/commands/cache.js b/lib/commands/cache.js index ecb34cb8916c4..b8f84abc1d941 100644 --- a/lib/commands/cache.js +++ b/lib/commands/cache.js @@ -81,6 +81,8 @@ class Cache extends BaseCommand { 'verify', ] + static ignoreImplicitWorkspace = true + async completion (opts) { const argv = opts.conf.argv.remain if (argv.length === 2) { diff --git a/lib/commands/help-search.js b/lib/commands/help-search.js index 6025a6dabd74b..9422b83561cc8 100644 --- a/lib/commands/help-search.js +++ b/lib/commands/help-search.js @@ -11,6 +11,7 @@ class HelpSearch extends BaseCommand { static name = 'help-search' static usage = [''] static params = ['long'] + static ignoreImplicitWorkspace = true async exec (args) { if (!args.length) { diff --git a/lib/commands/help.js b/lib/commands/help.js index f94178dd5d1d6..40f5ad9b30092 100644 --- a/lib/commands/help.js +++ b/lib/commands/help.js @@ -17,6 +17,7 @@ class Help extends BaseCommand { static name = 'help' static usage = [' []'] static params = ['viewer'] + static ignoreImplicitWorkspace = true async completion (opts) { if (opts.conf.argv.remain.length > 2) { diff --git a/lib/commands/hook.js b/lib/commands/hook.js index 2ff6ac01ce527..a4619802d8429 100644 --- a/lib/commands/hook.js +++ b/lib/commands/hook.js @@ -19,6 +19,8 @@ class Hook extends BaseCommand { 'update ', ] + static ignoreImplicitWorkspace = true + async exec (args) { return otplease({ ...this.npm.flatOptions, diff --git a/lib/commands/logout.js b/lib/commands/logout.js index aea5e93652b0e..7c2a7f0b2f830 100644 --- a/lib/commands/logout.js +++ b/lib/commands/logout.js @@ -11,6 +11,8 @@ class Logout extends BaseCommand { 'scope', ] + static ignoreImplicitWorkspace = true + async exec (args) { const registry = this.npm.config.get('registry') const scope = this.npm.config.get('scope') diff --git a/lib/commands/org.js b/lib/commands/org.js index f3d344ca33e3d..e2202a9e9cf3b 100644 --- a/lib/commands/org.js +++ b/lib/commands/org.js @@ -13,6 +13,7 @@ class Org extends BaseCommand { ] static params = ['registry', 'otp', 'json', 'parseable'] + static ignoreImplicitWorkspace = true async completion (opts) { const argv = opts.conf.argv.remain diff --git a/lib/commands/ping.js b/lib/commands/ping.js index 5a651c4a6ab09..22039214689a9 100644 --- a/lib/commands/ping.js +++ b/lib/commands/ping.js @@ -6,6 +6,7 @@ class Ping extends BaseCommand { static description = 'Ping npm registry' static params = ['registry'] static name = 'ping' + static ignoreImplicitWorkspace = true async exec (args) { log.notice('PING', this.npm.config.get('registry')) diff --git a/lib/commands/prefix.js b/lib/commands/prefix.js index 264b819fc7692..dd0e34c3d3bd9 100644 --- a/lib/commands/prefix.js +++ b/lib/commands/prefix.js @@ -5,6 +5,7 @@ class Prefix extends BaseCommand { static name = 'prefix' static params = ['global'] static usage = ['[-g]'] + static ignoreImplicitWorkspace = true async exec (args) { return this.npm.output(this.npm.prefix) diff --git a/lib/commands/profile.js b/lib/commands/profile.js index 6b4d1407f7919..a82d31fd443a9 100644 --- a/lib/commands/profile.js +++ b/lib/commands/profile.js @@ -54,6 +54,8 @@ class Profile extends BaseCommand { 'otp', ] + static ignoreImplicitWorkspace = true + async completion (opts) { var argv = opts.conf.argv.remain diff --git a/lib/commands/root.js b/lib/commands/root.js index 7749c602456b7..b814034def5ab 100644 --- a/lib/commands/root.js +++ b/lib/commands/root.js @@ -3,6 +3,7 @@ class Root extends BaseCommand { static description = 'Display npm root' static name = 'root' static params = ['global'] + static ignoreImplicitWorkspace = true async exec () { this.npm.output(this.npm.dir) diff --git a/lib/commands/search.js b/lib/commands/search.js index bdeeffe816980..a06ba4031443b 100644 --- a/lib/commands/search.js +++ b/lib/commands/search.js @@ -44,6 +44,7 @@ class Search extends BaseCommand { ] static usage = ['[search terms ...]'] + static ignoreImplicitWorkspace = true async exec (args) { const opts = { diff --git a/lib/npm.js b/lib/npm.js index 16c19f4cc1b7a..2906a5c00e26a 100644 --- a/lib/npm.js +++ b/lib/npm.js @@ -24,28 +24,6 @@ const _tmpFolder = Symbol('_tmpFolder') const _title = Symbol('_title') const pkg = require('../package.json') -const ignoreWorkspacesCommands = new Set([ - 'adduser', - 'access', - 'login', - 'bin', - 'birthday', - 'bugs', - 'cache', - 'help-search', - 'help', - 'hook', - 'logout', - 'org', - // 'owner', // TODO, this may need some workspace support - 'ping', - 'prefix', - 'profile', - // 'restart', // TODO add workspace support - 'root', - 'search', -]) - class Npm extends EventEmitter { static get version () { return pkg.version @@ -146,7 +124,7 @@ class Npm extends EventEmitter { // or when it is implicit and not in our ignore list const filterByWorkspaces = (workspacesEnabled || workspacesFilters.length > 0) - && (!implicitWorkspace || !ignoreWorkspacesCommands.has(cmd)) + && (!implicitWorkspace || !command.ignoreImplicitWorkspace) // 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 diff --git a/test/lib/npm.js b/test/lib/npm.js index 76b4aad1c6132..b2eedde72bc9d 100644 --- a/test/lib/npm.js +++ b/test/lib/npm.js @@ -575,7 +575,6 @@ t.test('implicit workspace rejection', async t => { }) const cwd = join(mock.npm.config.localPrefix, 'packages', 'a') mock.npm.config.set('workspace', [cwd], 'default') - console.log(mock.npm.config.get('workspace', 'default')) mockGlobals(t, { 'process.argv': [ process.execPath, From d11cf2af55a2ba03c152fdeefab598a376c2642b Mon Sep 17 00:00:00 2001 From: Nathan Fritz Date: Mon, 28 Feb 2022 11:45:35 -0800 Subject: [PATCH 3/4] fix: feedback, each command has static property --- lib/arborist-cmd.js | 2 ++ lib/base-command.js | 2 +- lib/commands/completion.js | 1 + lib/commands/config.js | 2 ++ lib/commands/deprecate.js | 2 ++ lib/commands/diff.js | 2 ++ lib/commands/dist-tag.js | 2 ++ lib/commands/docs.js | 1 + lib/commands/doctor.js | 1 + lib/commands/edit.js | 1 + lib/commands/exec.js | 2 ++ lib/commands/explain.js | 2 ++ lib/commands/explore.js | 1 + lib/commands/get.js | 1 + lib/commands/init.js | 2 ++ lib/commands/owner.js | 2 ++ lib/commands/pack.js | 1 + lib/commands/pkg.js | 2 ++ lib/commands/publish.js | 1 + lib/commands/repo.js | 1 + lib/commands/restart.js | 2 ++ lib/commands/run-script.js | 1 + lib/commands/set-script.js | 1 + lib/commands/set.js | 1 + lib/commands/shrinkwrap.js | 1 + lib/commands/star.js | 2 ++ lib/commands/stars.js | 1 + lib/commands/start.js | 2 ++ lib/commands/stop.js | 2 ++ lib/commands/team.js | 2 ++ lib/commands/test.js | 2 ++ lib/commands/token.js | 1 + lib/commands/uninstall.js | 1 + lib/commands/unpublish.js | 1 + lib/commands/version.js | 2 ++ lib/commands/view.js | 2 ++ lib/commands/whoami.js | 1 + test/lib/load-all-commands.js | 1 + 38 files changed, 56 insertions(+), 1 deletion(-) diff --git a/lib/arborist-cmd.js b/lib/arborist-cmd.js index 931ead8143dff..6518e91e0ad9d 100644 --- a/lib/arborist-cmd.js +++ b/lib/arborist-cmd.js @@ -14,6 +14,8 @@ class ArboristCmd extends BaseCommand { 'include-workspace-root', ] + static ignoreImplicitWorkspace = false + async execWorkspaces (args, filters) { await this.setWorkspaces(filters) return this.exec(args) diff --git a/lib/base-command.js b/lib/base-command.js index 6dc29c2badc60..b6e3d6d231860 100644 --- a/lib/base-command.js +++ b/lib/base-command.js @@ -21,7 +21,7 @@ class BaseCommand { } get ignoreImplicitWorkspace () { - return !!this.constructor.ignoreImplicitWorkspace + return this.constructor.ignoreImplicitWorkspace } get usage () { diff --git a/lib/commands/completion.js b/lib/commands/completion.js index 4ded2de385afb..0317753a15aaf 100644 --- a/lib/commands/completion.js +++ b/lib/commands/completion.js @@ -47,6 +47,7 @@ const BaseCommand = require('../base-command.js') class Completion extends BaseCommand { static description = 'Tab Completion for npm' static name = 'completion' + static ignoreImplicitWorkspace = false // completion for the completion command async completion (opts) { diff --git a/lib/commands/config.js b/lib/commands/config.js index 96524e00817f5..690a69a3233e4 100644 --- a/lib/commands/config.js +++ b/lib/commands/config.js @@ -61,6 +61,8 @@ class Config extends BaseCommand { 'long', ] + static ignoreImplicitWorkspace = false + async completion (opts) { const argv = opts.conf.argv.remain if (argv[1] !== 'config') { diff --git a/lib/commands/deprecate.js b/lib/commands/deprecate.js index 839e974caf09b..88eb320c32a52 100644 --- a/lib/commands/deprecate.js +++ b/lib/commands/deprecate.js @@ -15,6 +15,8 @@ class Deprecate extends BaseCommand { 'otp', ] + static ignoreImplicitWorkspace = false + async completion (opts) { if (opts.conf.argv.remain.length > 1) { return [] diff --git a/lib/commands/diff.js b/lib/commands/diff.js index d737a58dc43d8..ff942cc44e946 100644 --- a/lib/commands/diff.js +++ b/lib/commands/diff.js @@ -32,6 +32,8 @@ class Diff extends BaseCommand { 'include-workspace-root', ] + static ignoreImplicitWorkspace = false + async exec (args) { const specs = this.npm.config.get('diff').filter(d => d) if (specs.length > 2) { diff --git a/lib/commands/dist-tag.js b/lib/commands/dist-tag.js index bb36f3f72bfb2..3b82c5194cca8 100644 --- a/lib/commands/dist-tag.js +++ b/lib/commands/dist-tag.js @@ -16,6 +16,8 @@ class DistTag extends BaseCommand { 'ls []', ] + static ignoreImplicitWorkspace = false + async completion (opts) { const argv = opts.conf.argv.remain if (argv.length === 2) { diff --git a/lib/commands/docs.js b/lib/commands/docs.js index 19cd735642262..631615acc56b3 100644 --- a/lib/commands/docs.js +++ b/lib/commands/docs.js @@ -15,6 +15,7 @@ class Docs extends BaseCommand { ] static usage = ['[ [ ...]]'] + static ignoreImplicitWorkspace = false async exec (args) { if (!args || !args.length) { diff --git a/lib/commands/doctor.js b/lib/commands/doctor.js index 508faa57aa5e9..9af4c4cd6ffbf 100644 --- a/lib/commands/doctor.js +++ b/lib/commands/doctor.js @@ -41,6 +41,7 @@ class Doctor extends BaseCommand { static description = 'Check your npm environment' static name = 'doctor' static params = ['registry'] + static ignoreImplicitWorkspace = false async exec (args) { log.info('Running checkup') diff --git a/lib/commands/edit.js b/lib/commands/edit.js index 5f069c4f132e5..ce74ff79b2b7e 100644 --- a/lib/commands/edit.js +++ b/lib/commands/edit.js @@ -13,6 +13,7 @@ class Edit extends BaseCommand { static name = 'edit' static usage = ['[/...]'] static params = ['editor'] + static ignoreImplicitWorkspace = false // TODO /* istanbul ignore next */ diff --git a/lib/commands/exec.js b/lib/commands/exec.js index 52fb1f8eb7229..6b402c856ab1e 100644 --- a/lib/commands/exec.js +++ b/lib/commands/exec.js @@ -45,6 +45,8 @@ class Exec extends BaseCommand { '--package=foo -c \' [args...]\'', ] + static ignoreImplicitWorkspace = false + async exec (_args, { locationMsg, path, runPath } = {}) { if (!path) { path = this.npm.localPrefix diff --git a/lib/commands/explain.js b/lib/commands/explain.js index fd62b87fc869d..ca6ee7540bc91 100644 --- a/lib/commands/explain.js +++ b/lib/commands/explain.js @@ -16,6 +16,8 @@ class Explain extends ArboristWorkspaceCmd { 'workspace', ] + static ignoreImplicitWorkspace = false + // TODO /* istanbul ignore next */ async completion (opts) { diff --git a/lib/commands/explore.js b/lib/commands/explore.js index 90e6af69fe57c..5b97673b90eaa 100644 --- a/lib/commands/explore.js +++ b/lib/commands/explore.js @@ -13,6 +13,7 @@ class Explore extends BaseCommand { static name = 'explore' static usage = [' [ -- ]'] static params = ['shell'] + static ignoreImplicitWorkspace = false // TODO /* istanbul ignore next */ diff --git a/lib/commands/get.js b/lib/commands/get.js index 7583ade23d600..5e92e85a66382 100644 --- a/lib/commands/get.js +++ b/lib/commands/get.js @@ -4,6 +4,7 @@ class Get extends BaseCommand { static description = 'Get a value from the npm configuration' static name = 'get' static usage = ['[ ...] (See `npm config`)'] + static ignoreImplicitWorkspace = false // TODO /* istanbul ignore next */ diff --git a/lib/commands/init.js b/lib/commands/init.js index 367533f8259f5..2a6b6aaddc7e6 100644 --- a/lib/commands/init.js +++ b/lib/commands/init.js @@ -22,6 +22,8 @@ class Init extends BaseCommand { '[<@scope>/] (same as `npx [<@scope>/]create-`)', ] + static ignoreImplicitWorkspace = false + async exec (args) { // npm exec style if (args.length) { diff --git a/lib/commands/owner.js b/lib/commands/owner.js index effaaa6a53d3a..93e0a45ad1e27 100644 --- a/lib/commands/owner.js +++ b/lib/commands/owner.js @@ -20,6 +20,8 @@ class Owner extends BaseCommand { 'ls [<@scope>/]', ] + static ignoreImplicitWorkspace = false + async completion (opts) { const argv = opts.conf.argv.remain if (argv.length > 3) { diff --git a/lib/commands/pack.js b/lib/commands/pack.js index 74c29699a05c9..41fef5cb45a47 100644 --- a/lib/commands/pack.js +++ b/lib/commands/pack.js @@ -18,6 +18,7 @@ class Pack extends BaseCommand { ] static usage = ['[[<@scope>/]...]'] + static ignoreImplicitWorkspace = false async exec (args) { if (args.length === 0) { diff --git a/lib/commands/pkg.js b/lib/commands/pkg.js index 6ca892293cebe..3a8e01f65bc92 100644 --- a/lib/commands/pkg.js +++ b/lib/commands/pkg.js @@ -20,6 +20,8 @@ class Pkg extends BaseCommand { 'workspaces', ] + static ignoreImplicitWorkspace = false + async exec (args, { prefix } = {}) { if (!prefix) { this.prefix = this.npm.localPrefix diff --git a/lib/commands/publish.js b/lib/commands/publish.js index d1f0ee743cfcc..cadc67e8b5a32 100644 --- a/lib/commands/publish.js +++ b/lib/commands/publish.js @@ -39,6 +39,7 @@ class Publish extends BaseCommand { ] static usage = ['[]'] + static ignoreImplicitWorkspace = false async exec (args) { if (args.length === 0) { diff --git a/lib/commands/repo.js b/lib/commands/repo.js index 8ac4178f261ee..b8dccc209ff87 100644 --- a/lib/commands/repo.js +++ b/lib/commands/repo.js @@ -10,6 +10,7 @@ class Repo extends BaseCommand { static name = 'repo' static params = ['browser', 'workspace', 'workspaces', 'include-workspace-root'] static usage = ['[ [ ...]]'] + static ignoreImplicitWorkspace = false async exec (args) { if (!args || !args.length) { diff --git a/lib/commands/restart.js b/lib/commands/restart.js index a12368644a13b..575928b2202cc 100644 --- a/lib/commands/restart.js +++ b/lib/commands/restart.js @@ -8,5 +8,7 @@ class Restart extends LifecycleCmd { 'ignore-scripts', 'script-shell', ] + + static ignoreImplicitWorkspace = false } module.exports = Restart diff --git a/lib/commands/run-script.js b/lib/commands/run-script.js index edba95821b44c..74757e984aeed 100644 --- a/lib/commands/run-script.js +++ b/lib/commands/run-script.js @@ -40,6 +40,7 @@ class RunScript extends BaseCommand { static name = 'run-script' static usage = [' [-- ]'] + static ignoreImplicitWorkspace = false async completion (opts) { const argv = opts.conf.argv.remain diff --git a/lib/commands/set-script.js b/lib/commands/set-script.js index 7c73ff01b9396..a6b7c3a50cdaf 100644 --- a/lib/commands/set-script.js +++ b/lib/commands/set-script.js @@ -9,6 +9,7 @@ class SetScript extends BaseCommand { static params = ['workspace', 'workspaces', 'include-workspace-root'] static name = 'set-script' static usage = ['[