From ccb03b409bfcd701d76017d3dc03a20219f1908f Mon Sep 17 00:00:00 2001 From: Mario Nebl Date: Sat, 3 Feb 2018 12:48:18 +0100 Subject: [PATCH] fix(parse): default to angular preset for empty parserOpts (#265) Closes #262 --- @commitlint/parse/src/index.js | 2 +- @commitlint/parse/src/index.test.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/@commitlint/parse/src/index.js b/@commitlint/parse/src/index.js index fc0e5b16a6..0c71d40e2f 100644 --- a/@commitlint/parse/src/index.js +++ b/@commitlint/parse/src/index.js @@ -4,7 +4,7 @@ import defaultChangelogOpts from 'conventional-changelog-angular'; export default parse; async function parse(message, parser = sync, parserOpts) { - if (!parserOpts) { + if (!parserOpts || Object.keys(parserOpts || {}).length === 0) { const changelogOpts = await defaultChangelogOpts; parserOpts = changelogOpts.parserOpts; } diff --git a/@commitlint/parse/src/index.test.js b/@commitlint/parse/src/index.test.js index f4afab09b8..78d7aa7d73 100644 --- a/@commitlint/parse/src/index.test.js +++ b/@commitlint/parse/src/index.test.js @@ -105,6 +105,13 @@ test('supports scopes with /', async t => { t.is(actual.subject, 'subject'); }); +test('supports scopes with / and empty parserOpts', async t => { + const message = 'type(some/scope): subject'; + const actual = await parse(message, undefined, {}); + t.is(actual.scope, 'some/scope'); + t.is(actual.subject, 'subject'); +}); + test('ignores comments', async t => { const message = 'type(some/scope): subject\n# some comment'; const changelogOpts = await importFrom(