Skip to content

Commit

Permalink
Do not test new version with pkg.version (#3103)
Browse files Browse the repository at this point in the history
See issue 3011 for details. Leave it to
npm registry to validate the version number.
  • Loading branch information
binarykitchen authored and bestander committed Apr 21, 2017
1 parent 9786322 commit e7e2aa7
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
8 changes: 8 additions & 0 deletions __tests__/commands/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ test('run version with no arguments and --new-version flag', (): Promise<void> =
});
});

test('run version with no arguments, --new-version flag where version is same as pkg.version', (): Promise<void> => {
return runRun([], {newVersion, gitTagVersion}, 'no-args-same-version', async(config, reporter): ?Promise<void> => {
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<void> => {
return runRun([], {newVersion, gitTagVersion}, 'no-args', async(config): ?Promise<void> => {
const pkg = await fs.readJson(path.join(config.cwd, 'package.json'));
Expand Down
9 changes: 9 additions & 0 deletions __tests__/fixtures/version/no-args-same-version/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"version": "2.0.0",
"license": "BSD-2-Clause",
"scripts": {
"preversion": "echo preversion",
"version": "echo version",
"postversion": "echo postversion"
}
}
4 changes: 3 additions & 1 deletion src/cli/commands/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ export async function setVersion(
invariant(newVersion, 'expected new version');

if (newVersion === pkg.version) {
throw new MessageError(reporter.lang('publishSame'));
return function(): Promise<void> {
return Promise.resolve();
};
}

await runLifecycle('preversion');
Expand Down
1 change: 0 additions & 1 deletion src/reporters/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,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.',
Expand Down

0 comments on commit e7e2aa7

Please sign in to comment.