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

feat(cli): add helpurl flag #789

Merged
merged 2 commits into from Sep 23, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions @commitlint/cli/src/cli.js
Expand Up @@ -56,6 +56,11 @@ const flags = {
type: 'boolean',
description: 'display this help message'
},
'help-url': {
alias: 'H',
type: 'string',
description: 'helpurl in error message'
},
from: {
alias: 'f',
default: null,
Expand Down Expand Up @@ -220,8 +225,9 @@ async function main(options) {
const output = format(report, {
color: flags.color,
verbose: flags.verbose,
helpUrl:
'https://github.com/conventional-changelog/commitlint/#what-is-commitlint'
helpUrl: flags.helpUrl
? flags.helpUrl.trim()
: 'https://github.com/conventional-changelog/commitlint/#what-is-commitlint'
});

if (!flags.quiet && output !== '') {
Expand Down
14 changes: 14 additions & 0 deletions @commitlint/cli/src/cli.test.js
Expand Up @@ -71,6 +71,20 @@ test('should produce help for problems', async t => {
t.is(actual.code, 1);
});

test('should produce help for problems with correct helpurl', async t => {
const cwd = await git.bootstrap('fixtures/default');
const actual = await cli(
['-H https://github.com/conventional-changelog/commitlint/#testhelpurl'],
{cwd}
)('foo: bar');
t.true(
actual.stdout.includes(
'Get help: https://github.com/conventional-changelog/commitlint/#testhelpurl'
)
);
t.is(actual.code, 1);
});

test('should fail for input from stdin without rules', async t => {
const cwd = await git.bootstrap('fixtures/empty');
const actual = await cli([], {cwd})('foo: bar');
Expand Down