Skip to content

Commit 75cef4e

Browse files
AnWebermarionebl
authored andcommitted
feat(cli): add helpurl flag (#789)
* feat(cli): add helpurl flag * fix(cli): remove space before helpurl
1 parent ba5fcb6 commit 75cef4e

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

@commitlint/cli/src/cli.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ const flags = {
5656
type: 'boolean',
5757
description: 'display this help message'
5858
},
59+
'help-url': {
60+
alias: 'H',
61+
type: 'string',
62+
description: 'helpurl in error message'
63+
},
5964
from: {
6065
alias: 'f',
6166
default: null,
@@ -220,8 +225,9 @@ async function main(options) {
220225
const output = format(report, {
221226
color: flags.color,
222227
verbose: flags.verbose,
223-
helpUrl:
224-
'https://github.com/conventional-changelog/commitlint/#what-is-commitlint'
228+
helpUrl: flags.helpUrl
229+
? flags.helpUrl.trim()
230+
: 'https://github.com/conventional-changelog/commitlint/#what-is-commitlint'
225231
});
226232

227233
if (!flags.quiet && output !== '') {

@commitlint/cli/src/cli.test.js

+14
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,20 @@ test('should produce help for problems', async t => {
7171
t.is(actual.code, 1);
7272
});
7373

74+
test('should produce help for problems with correct helpurl', async t => {
75+
const cwd = await git.bootstrap('fixtures/default');
76+
const actual = await cli(
77+
['-H https://github.com/conventional-changelog/commitlint/#testhelpurl'],
78+
{cwd}
79+
)('foo: bar');
80+
t.true(
81+
actual.stdout.includes(
82+
'Get help: https://github.com/conventional-changelog/commitlint/#testhelpurl'
83+
)
84+
);
85+
t.is(actual.code, 1);
86+
});
87+
7488
test('should fail for input from stdin without rules', async t => {
7589
const cwd = await git.bootstrap('fixtures/empty');
7690
const actual = await cli([], {cwd})('foo: bar');

0 commit comments

Comments
 (0)