diff --git a/lib/commands/version.js b/lib/commands/version.js index 67b17cfbf3967..9b8a295b95cc4 100644 --- a/lib/commands/version.js +++ b/lib/commands/version.js @@ -22,7 +22,6 @@ class Version extends BaseCommand { ] static workspaces = true - static ignoreImplicitWorkspace = false static skipConfigValidation = true static usage = ['[ | major | minor | patch | premajor | preminor | prepatch | prerelease | from-git]'] diff --git a/test/lib/commands/version.js b/test/lib/commands/version.js index 35987ed83cb7a..3c41991968f29 100644 --- a/test/lib/commands/version.js +++ b/test/lib/commands/version.js @@ -258,6 +258,46 @@ t.test('empty versions', async t => { t.matchSnapshot(readFileSync(resolve(prefix, 'package-lock.json'), 'utf8')) }) + t.test('with one arg in an implicit workspace', async t => { + const paths = [] + const { version, prefix } = await mockNpm(t, { + prefixDir: { + 'package.json': JSON.stringify({ + name: 'workspaces-test', + version: '1.0.0', + workspaces: ['workspace-a', 'workspace-b'], + }), + 'workspace-a': { + 'package.json': JSON.stringify({ + name: 'workspace-a', + version: '1.0.0', + }), + }, + 'workspace-b': { + 'package.json': JSON.stringify({ + name: 'workspace-b', + version: '1.0.0', + }), + }, + }, + chdir: ({ prefix }) => resolve(prefix, 'workspace-a'), + config: { + 'workspaces-update': false, + }, + mocks: { + libnpmversion: (_version, opts) => { + paths.push(opts.path) + return '1.0.1' + }, + }, + }) + + await version.exec(['patch']) + + t.strictSame(paths, [resolve(prefix, 'workspace-a')], + 'only versions the implicit workspace') + }) + t.test('with one arg, all workspaces, saves package.json', async t => { const { version, outputs, prefix } = await mockNpm(t, { prefixDir: {