Skip to content

Commit

Permalink
chore: update conventional-changelog packages
Browse files Browse the repository at this point in the history
closes #115
  • Loading branch information
marionebl committed Dec 8, 2017
1 parent 7975967 commit 35d0ca5
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 36 deletions.
12 changes: 8 additions & 4 deletions @commitlint/cli/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,13 @@ async function main(options) {
messages.map(async message => {
const loaded = await core.load(getSeed(flags), {cwd: flags.cwd});
const parserOpts = selectParserOpts(loaded.parserPreset);
const opts = parserOpts ? {parserOpts} : undefined;
const opts = parserOpts ? {parserOpts} : {parserOpts: {}};

// Strip comments if reading from `.git/COMMIT_EDIT_MSG`
if (range.edit) {
opts.parserOpts.commentChar = '#';
}

const report = await core.lint(message, loaded.rules, opts);
const formatted = core.format(report, {color: flags.color});

Expand Down Expand Up @@ -154,9 +160,7 @@ function normalizeEdit(edit) {
if (edit === '$GIT_PARAMS' || edit === '%GIT_PARAMS%') {
if (!('GIT_PARAMS' in process.env)) {
throw new Error(
`Received ${
edit
} as value for -e | --edit, but GIT_PARAMS is not available globally.`
`Received ${edit} as value for -e | --edit, but GIT_PARAMS is not available globally.`
);
}
return process.env.GIT_PARAMS;
Expand Down
4 changes: 2 additions & 2 deletions @commitlint/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@
"xo": "0.18.2"
},
"dependencies": {
"@marionebl/conventional-commits-parser": "^3.0.0",
"@marionebl/git-raw-commits": "^1.2.0",
"@marionebl/sander": "^0.6.0",
"babel-runtime": "^6.23.0",
"chalk": "^2.0.1",
"conventional-changelog-angular": "^1.3.3",
"conventional-commits-parser": "^2.1.0",
"cosmiconfig": "^3.0.1",
"find-up": "^2.1.0",
"git-raw-commits": "^1.3.0",
"lodash": "^4.17.4",
"require-uncached": "^1.0.3",
"resolve-from": "^4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion @commitlint/core/src/library/parse.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {sync} from '@marionebl/conventional-commits-parser';
import {sync} from 'conventional-commits-parser';
import defaultChangelogOpts from 'conventional-changelog-angular';

export default parse;
Expand Down
24 changes: 22 additions & 2 deletions @commitlint/core/src/library/parse.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,12 @@ test('supports scopes with /', async t => {

test('ignores comments', async t => {
const message = 'type(some/scope): subject\n# some comment';
const actual = await parse(message);
const changelogOpts = await importFrom(
process.cwd(),
'conventional-changelog-angular'
);
const opts = Object.assign({}, changelogOpts.parserOpts, {commentChar: '#'});
const actual = await parse(message, undefined, opts);
t.is(actual.body, null);
t.is(actual.footer, null);
t.is(actual.subject, 'subject');
Expand All @@ -116,7 +121,22 @@ test('ignores comments', async t => {
test('registers inline #', async t => {
const message =
'type(some/scope): subject #reference\n# some comment\nthings #reference';
const actual = await parse(message);
const changelogOpts = await importFrom(
process.cwd(),
'conventional-changelog-angular'
);
const opts = Object.assign({}, changelogOpts.parserOpts, {commentChar: '#'});
const actual = await parse(message, undefined, opts);
t.is(actual.subject, 'subject #reference');
t.is(actual.body, 'things #reference');
});

test('parses references leading subject', async t => {
const message = '#1 some subject';
const opts = await importFrom(
process.cwd(),
'conventional-changelog-angular'
);
const {references: [actual]} = await parse(message, undefined, opts);
t.is(actual.issue, '1');
});
2 changes: 1 addition & 1 deletion @commitlint/core/src/read.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'path';
import gitRawCommits from '@marionebl/git-raw-commits';
import gitRawCommits from 'git-raw-commits';
import * as sander from '@marionebl/sander';

import toplevel from './library/toplevel';
Expand Down
19 changes: 15 additions & 4 deletions @commitlint/core/src/rules/references-empty.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import test from 'ava';
import preset from 'conventional-changelog-angular';
import parse from '../library/parse';
import referencesEmpty from './references-empty';

Expand All @@ -9,11 +10,21 @@ const messages = {
references: '#comment\nfoo: bar \nCloses #1, #2, #3'
};

const opts = (async () => {
const o = await preset;
o.parserOpts.commentChar = '#';
return o;
})();

const parsed = {
plain: parse(messages.plain),
comment: parse(messages.comment),
reference: parse(messages.reference),
references: parse(messages.references)
plain: (async () =>
parse(messages.plain, undefined, (await opts).parserOpts))(),
comment: (async () =>
parse(messages.comment, undefined, (await opts).parserOpts))(),
reference: (async () =>
parse(messages.reference, undefined, (await opts).parserOpts))(),
references: (async () =>
parse(messages.references, undefined, (await opts).parserOpts))()
};

test('defaults to never and fails for plain', async t => {
Expand Down
34 changes: 12 additions & 22 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -59,28 +59,6 @@
dependencies:
arrify "^1.0.1"

"@marionebl/conventional-commits-parser@^3.0.0":
version "3.0.0"
resolved "https://registry.npmjs.org/@marionebl/conventional-commits-parser/-/conventional-commits-parser-3.0.0.tgz#9da29b4d2c8f05c0f9cdd02936713b8096c958d3"
dependencies:
JSONStream "^1.0.4"
is-text-path "^1.0.0"
lodash "^4.2.1"
meow "^3.3.0"
split2 "^2.0.0"
through2 "^2.0.0"
trim-off-newlines "^1.0.0"

"@marionebl/git-raw-commits@^1.2.0":
version "1.2.0"
resolved "https://registry.npmjs.org/@marionebl/git-raw-commits/-/git-raw-commits-1.2.0.tgz#7cd8a6dfc09a96df98d8fbe9175c5971cc07c82b"
dependencies:
dargs "^4.0.1"
lodash.template "^4.0.2"
meow "^3.3.0"
split2 "^2.0.0"
through2 "^2.0.0"

"@marionebl/sander@0.6.1", "@marionebl/sander@^0.6.0":
version "0.6.1"
resolved "https://registry.npmjs.org/@marionebl/sander/-/sander-0.6.1.tgz#1958965874f24bc51be48875feb50d642fc41f7b"
Expand Down Expand Up @@ -1913,6 +1891,18 @@ conventional-commits-parser@^2.0.1:
through2 "^2.0.0"
trim-off-newlines "^1.0.0"

conventional-commits-parser@^2.1.0:
version "2.1.0"
resolved "https://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-2.1.0.tgz#9b4b7c91124bf2a1a9a2cc1c72760d382cbbb229"
dependencies:
JSONStream "^1.0.4"
is-text-path "^1.0.0"
lodash "^4.2.1"
meow "^3.3.0"
split2 "^2.0.0"
through2 "^2.0.0"
trim-off-newlines "^1.0.0"

conventional-recommended-bump@^1.0.1:
version "1.0.3"
resolved "https://registry.npmjs.org/conventional-recommended-bump/-/conventional-recommended-bump-1.0.3.tgz#472b69b1b8f09c5c4ed40fe28a41e63cc04bd736"
Expand Down

0 comments on commit 35d0ca5

Please sign in to comment.