diff --git a/@commitlint/cli/src/cli.js b/@commitlint/cli/src/cli.js index cad49f191f..b71c030c9f 100755 --- a/@commitlint/cli/src/cli.js +++ b/@commitlint/cli/src/cli.js @@ -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, @@ -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 !== '') { diff --git a/@commitlint/cli/src/cli.test.js b/@commitlint/cli/src/cli.test.js index 692497064e..2ea093e8be 100644 --- a/@commitlint/cli/src/cli.test.js +++ b/@commitlint/cli/src/cli.test.js @@ -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');