Skip to content

Commit

Permalink
feat(cli): add helpurl flag (#789)
Browse files Browse the repository at this point in the history
* feat(cli): add helpurl flag

* fix(cli): remove space before helpurl
  • Loading branch information
AnWeber authored and marionebl committed Sep 23, 2019
1 parent ba5fcb6 commit 75cef4e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
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

0 comments on commit 75cef4e

Please sign in to comment.