From bb45d7fd6c6290a93c07abb1cc2a477523ea84f1 Mon Sep 17 00:00:00 2001 From: Andreas Weber Date: Tue, 17 Sep 2019 09:46:59 +0200 Subject: [PATCH 1/2] feat(cli): add helpurl flag --- @commitlint/cli/src/cli.js | 6 ++++++ @commitlint/cli/src/cli.test.js | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/@commitlint/cli/src/cli.js b/@commitlint/cli/src/cli.js index cad49f191f..e638f7749e 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, @@ -221,6 +226,7 @@ async function main(options) { color: flags.color, verbose: flags.verbose, helpUrl: + flags.helpUrl || 'https://github.com/conventional-changelog/commitlint/#what-is-commitlint' }); 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'); From 9923f6835c7a022c3771c61ee2fa803f5725812e Mon Sep 17 00:00:00 2001 From: Andreas Weber Date: Tue, 17 Sep 2019 10:15:55 +0200 Subject: [PATCH 2/2] fix(cli): remove space before helpurl --- @commitlint/cli/src/cli.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/@commitlint/cli/src/cli.js b/@commitlint/cli/src/cli.js index e638f7749e..b71c030c9f 100755 --- a/@commitlint/cli/src/cli.js +++ b/@commitlint/cli/src/cli.js @@ -225,9 +225,9 @@ async function main(options) { const output = format(report, { color: flags.color, verbose: flags.verbose, - helpUrl: - flags.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 !== '') {