Skip to content

Commit

Permalink
fix(version): Exit with an error when --github-release is combined …
Browse files Browse the repository at this point in the history
…with `--no-changelog`
  • Loading branch information
evocateur committed Feb 11, 2019
1 parent 83c33a3 commit 030de9d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions commands/version/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ To authenticate with GitHub, the following environment variables can be defined.
- `GHE_API_URL` - When using GitHub Enterprise, an absolute URL to the API.
- `GHE_VERSION` - When using GitHub Enterprise, the currently installed GHE version. [Supports the following versions](https://github.com/octokit/plugin-enterprise-rest.js).

> NOTE: When using this option, you cannot pass [`--no-changelog`](#--no-changelog).
### `--ignore-changes`

Ignore changes in files matched by glob(s) when detecting changed packages.
Expand Down Expand Up @@ -252,6 +254,8 @@ lerna version --conventional-commits --no-changelog

When using `conventional-commits`, do not generate any `CHANGELOG.md` files.

> NOTE: When using this option, you cannot pass [`--github-release`](#--github-release).
### `--no-commit-hooks`

By default, `lerna version` will allow git commit hooks to run when committing version changes.
Expand Down
13 changes: 13 additions & 0 deletions commands/version/__tests__/version-github-release.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ test("--github-release throws an error if --conventional-commits is not passed",
expect.hasAssertions();
});

test("--github-release throws an error if --no-changelog also passed", async () => {
const cwd = await initFixture("independent");

try {
await lernaVersion(cwd)("--github-release", "--conventional-commits", "--no-changelog");
} catch (err) {
expect(err.message).toBe("To create a Github Release, you cannot pass --no-changelog");
expect(client.repos.createRelease).not.toHaveBeenCalled();
}

expect.hasAssertions();
});

test("--github-release marks a version as a pre-release if it contains a valid part", async () => {
const cwd = await initFixture("normal");

Expand Down
4 changes: 4 additions & 0 deletions commands/version/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ class VersionCommand extends Command {
);
}

if (this.createReleases && this.options.changelog === false) {
throw new ValidationError("ERELEASE", "To create a Github Release, you cannot pass --no-changelog");
}

this.gitOpts = {
amend,
commitHooks,
Expand Down

0 comments on commit 030de9d

Please sign in to comment.