Skip to content

Do not test new version with pkg.version #3103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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<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 @@ -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.',
Expand Down