diff --git a/__tests__/commands/version.js b/__tests__/commands/version.js index 1c3e0ec1d7..781adf6a97 100644 --- a/__tests__/commands/version.js +++ b/__tests__/commands/version.js @@ -39,6 +39,14 @@ test('run version with no arguments and --new-version flag', (): Promise = }); }); +test('run version with no arguments, --new-version flag where version is same as pkg.version', (): Promise => { + return runRun([], {newVersion, gitTagVersion}, 'no-args-same-version', async(config, reporter): ?Promise => { + const pkg = await fs.readJson(path.join(config.cwd, 'package.json')); + + expect(pkg.version).toEqual(newVersion); + }); +}); + test('run version and make sure all lifecycle steps are executed', (): Promise => { return runRun([], {newVersion, gitTagVersion}, 'no-args', async(config): ?Promise => { const pkg = await fs.readJson(path.join(config.cwd, 'package.json')); diff --git a/__tests__/fixtures/version/no-args-same-version/package.json b/__tests__/fixtures/version/no-args-same-version/package.json new file mode 100644 index 0000000000..1a4372ecf5 --- /dev/null +++ b/__tests__/fixtures/version/no-args-same-version/package.json @@ -0,0 +1,9 @@ +{ + "version": "2.0.0", + "license": "BSD-2-Clause", + "scripts": { + "preversion": "echo preversion", + "version": "echo version", + "postversion": "echo postversion" + } +} diff --git a/src/cli/commands/version.js b/src/cli/commands/version.js index ad3d25cc54..96b016677a 100644 --- a/src/cli/commands/version.js +++ b/src/cli/commands/version.js @@ -90,7 +90,9 @@ export async function setVersion( invariant(newVersion, 'expected new version'); if (newVersion === pkg.version) { - throw new MessageError(reporter.lang('publishSame')); + return function(): Promise { + return Promise.resolve(); + }; } await runLifecycle('preversion'); diff --git a/src/reporters/lang/en.js b/src/reporters/lang/en.js index 37db734d33..8e27dcd53b 100644 --- a/src/reporters/lang/en.js +++ b/src/reporters/lang/en.js @@ -218,7 +218,6 @@ const messages = { incorrectCredentials: 'Incorrect username or password.', clearedCredentials: 'Cleared login credentials.', - publishSame: 'New version is the same as the current version.', publishFail: "Couldn't publish package.", publishPrivate: 'Package marked as private, not publishing.', published: 'Published.',