Skip to content
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

Add ability to publish non-interactively without version bumping #5748

Merged
merged 2 commits into from
Jun 6, 2018
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
14 changes: 6 additions & 8 deletions __tests__/commands/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,12 @@ test('run version with --non-interactive and --new-version should succeed', ():
});
});

test('run version with --non-interactive and without --new-version should fail', async (): Promise<void> => {
let thrown = false;
try {
await runRun([], {nonInteractive: true}, 'no-args');
} catch (e) {
thrown = true;
}
expect(thrown).toEqual(true);
test('run version with --non-interactive and without --new-version should succeed', (): Promise<void> => {
return runRun([], {nonInteractive: true}, 'no-args', async (config, reporter): ?Promise<void> => {
const pkg = await fs.readJson(path.join(config.cwd, 'package.json'));

expect(pkg.version).toEqual(oldVersion);
});
});

test('run version and make sure all lifecycle steps are executed', (): Promise<void> => {
Expand Down
6 changes: 2 additions & 4 deletions __tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,8 @@ test.concurrent('should show version of yarn with -v', async () => {
});

test.concurrent('should run version command', async () => {
await expectAnErrorMessage(
execCommand('version', [], 'run-version'),
'You must specify a new version with --new-version when running with --non-interactive.',
);
const stdout = await execCommand('version', [], 'run-version');
expect(stdout[0]).toEqual(`yarn version v${pkg.version}`);
});

test.concurrent('should run --version command', async () => {
Expand Down
4 changes: 3 additions & 1 deletion src/cli/commands/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ export async function setVersion(
while (!newVersion) {
// make sure we're not running in non-interactive mode before asking for new version
if (flags.nonInteractive || config.nonInteractive) {
throw new MessageError(reporter.lang('nonInteractiveNoVersionSpecified'));
// if no version is specified, use current version in package.json
newVersion = oldVersion;
break;
}

newVersion = await reporter.question(reporter.lang('newVersion'));
Expand Down