Skip to content

Commit 35d0ca5

Browse files
committed
chore: update conventional-changelog packages
closes #115
1 parent 7975967 commit 35d0ca5

File tree

7 files changed

+61
-36
lines changed

7 files changed

+61
-36
lines changed

@commitlint/cli/src/cli.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,13 @@ async function main(options) {
9999
messages.map(async message => {
100100
const loaded = await core.load(getSeed(flags), {cwd: flags.cwd});
101101
const parserOpts = selectParserOpts(loaded.parserPreset);
102-
const opts = parserOpts ? {parserOpts} : undefined;
102+
const opts = parserOpts ? {parserOpts} : {parserOpts: {}};
103+
104+
// Strip comments if reading from `.git/COMMIT_EDIT_MSG`
105+
if (range.edit) {
106+
opts.parserOpts.commentChar = '#';
107+
}
108+
103109
const report = await core.lint(message, loaded.rules, opts);
104110
const formatted = core.format(report, {color: flags.color});
105111

@@ -154,9 +160,7 @@ function normalizeEdit(edit) {
154160
if (edit === '$GIT_PARAMS' || edit === '%GIT_PARAMS%') {
155161
if (!('GIT_PARAMS' in process.env)) {
156162
throw new Error(
157-
`Received ${
158-
edit
159-
} as value for -e | --edit, but GIT_PARAMS is not available globally.`
163+
`Received ${edit} as value for -e | --edit, but GIT_PARAMS is not available globally.`
160164
);
161165
}
162166
return process.env.GIT_PARAMS;

@commitlint/core/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@
7070
"xo": "0.18.2"
7171
},
7272
"dependencies": {
73-
"@marionebl/conventional-commits-parser": "^3.0.0",
74-
"@marionebl/git-raw-commits": "^1.2.0",
7573
"@marionebl/sander": "^0.6.0",
7674
"babel-runtime": "^6.23.0",
7775
"chalk": "^2.0.1",
7876
"conventional-changelog-angular": "^1.3.3",
77+
"conventional-commits-parser": "^2.1.0",
7978
"cosmiconfig": "^3.0.1",
8079
"find-up": "^2.1.0",
80+
"git-raw-commits": "^1.3.0",
8181
"lodash": "^4.17.4",
8282
"require-uncached": "^1.0.3",
8383
"resolve-from": "^4.0.0",

@commitlint/core/src/library/parse.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {sync} from '@marionebl/conventional-commits-parser';
1+
import {sync} from 'conventional-commits-parser';
22
import defaultChangelogOpts from 'conventional-changelog-angular';
33

44
export default parse;

@commitlint/core/src/library/parse.test.js

+22-2
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,12 @@ test('supports scopes with /', async t => {
107107

108108
test('ignores comments', async t => {
109109
const message = 'type(some/scope): subject\n# some comment';
110-
const actual = await parse(message);
110+
const changelogOpts = await importFrom(
111+
process.cwd(),
112+
'conventional-changelog-angular'
113+
);
114+
const opts = Object.assign({}, changelogOpts.parserOpts, {commentChar: '#'});
115+
const actual = await parse(message, undefined, opts);
111116
t.is(actual.body, null);
112117
t.is(actual.footer, null);
113118
t.is(actual.subject, 'subject');
@@ -116,7 +121,22 @@ test('ignores comments', async t => {
116121
test('registers inline #', async t => {
117122
const message =
118123
'type(some/scope): subject #reference\n# some comment\nthings #reference';
119-
const actual = await parse(message);
124+
const changelogOpts = await importFrom(
125+
process.cwd(),
126+
'conventional-changelog-angular'
127+
);
128+
const opts = Object.assign({}, changelogOpts.parserOpts, {commentChar: '#'});
129+
const actual = await parse(message, undefined, opts);
120130
t.is(actual.subject, 'subject #reference');
121131
t.is(actual.body, 'things #reference');
122132
});
133+
134+
test('parses references leading subject', async t => {
135+
const message = '#1 some subject';
136+
const opts = await importFrom(
137+
process.cwd(),
138+
'conventional-changelog-angular'
139+
);
140+
const {references: [actual]} = await parse(message, undefined, opts);
141+
t.is(actual.issue, '1');
142+
});

@commitlint/core/src/read.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import path from 'path';
2-
import gitRawCommits from '@marionebl/git-raw-commits';
2+
import gitRawCommits from 'git-raw-commits';
33
import * as sander from '@marionebl/sander';
44

55
import toplevel from './library/toplevel';

@commitlint/core/src/rules/references-empty.test.js

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import test from 'ava';
2+
import preset from 'conventional-changelog-angular';
23
import parse from '../library/parse';
34
import referencesEmpty from './references-empty';
45

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

13+
const opts = (async () => {
14+
const o = await preset;
15+
o.parserOpts.commentChar = '#';
16+
return o;
17+
})();
18+
1219
const parsed = {
13-
plain: parse(messages.plain),
14-
comment: parse(messages.comment),
15-
reference: parse(messages.reference),
16-
references: parse(messages.references)
20+
plain: (async () =>
21+
parse(messages.plain, undefined, (await opts).parserOpts))(),
22+
comment: (async () =>
23+
parse(messages.comment, undefined, (await opts).parserOpts))(),
24+
reference: (async () =>
25+
parse(messages.reference, undefined, (await opts).parserOpts))(),
26+
references: (async () =>
27+
parse(messages.references, undefined, (await opts).parserOpts))()
1728
};
1829

1930
test('defaults to never and fails for plain', async t => {

yarn.lock

+12-22
Original file line numberDiff line numberDiff line change
@@ -59,28 +59,6 @@
5959
dependencies:
6060
arrify "^1.0.1"
6161

62-
"@marionebl/conventional-commits-parser@^3.0.0":
63-
version "3.0.0"
64-
resolved "https://registry.npmjs.org/@marionebl/conventional-commits-parser/-/conventional-commits-parser-3.0.0.tgz#9da29b4d2c8f05c0f9cdd02936713b8096c958d3"
65-
dependencies:
66-
JSONStream "^1.0.4"
67-
is-text-path "^1.0.0"
68-
lodash "^4.2.1"
69-
meow "^3.3.0"
70-
split2 "^2.0.0"
71-
through2 "^2.0.0"
72-
trim-off-newlines "^1.0.0"
73-
74-
"@marionebl/git-raw-commits@^1.2.0":
75-
version "1.2.0"
76-
resolved "https://registry.npmjs.org/@marionebl/git-raw-commits/-/git-raw-commits-1.2.0.tgz#7cd8a6dfc09a96df98d8fbe9175c5971cc07c82b"
77-
dependencies:
78-
dargs "^4.0.1"
79-
lodash.template "^4.0.2"
80-
meow "^3.3.0"
81-
split2 "^2.0.0"
82-
through2 "^2.0.0"
83-
8462
"@marionebl/[email protected]", "@marionebl/sander@^0.6.0":
8563
version "0.6.1"
8664
resolved "https://registry.npmjs.org/@marionebl/sander/-/sander-0.6.1.tgz#1958965874f24bc51be48875feb50d642fc41f7b"
@@ -1913,6 +1891,18 @@ conventional-commits-parser@^2.0.1:
19131891
through2 "^2.0.0"
19141892
trim-off-newlines "^1.0.0"
19151893

1894+
conventional-commits-parser@^2.1.0:
1895+
version "2.1.0"
1896+
resolved "https://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-2.1.0.tgz#9b4b7c91124bf2a1a9a2cc1c72760d382cbbb229"
1897+
dependencies:
1898+
JSONStream "^1.0.4"
1899+
is-text-path "^1.0.0"
1900+
lodash "^4.2.1"
1901+
meow "^3.3.0"
1902+
split2 "^2.0.0"
1903+
through2 "^2.0.0"
1904+
trim-off-newlines "^1.0.0"
1905+
19161906
conventional-recommended-bump@^1.0.1:
19171907
version "1.0.3"
19181908
resolved "https://registry.npmjs.org/conventional-recommended-bump/-/conventional-recommended-bump-1.0.3.tgz#472b69b1b8f09c5c4ed40fe28a41e63cc04bd736"

0 commit comments

Comments
 (0)