Skip to content

Commit c9c968d

Browse files
authored
refactor(parse): refactor parse to use object spread (#977)
1 parent 9c5ec16 commit c9c968d

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

@commitlint/parse/package.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,10 @@
3535
"license": "MIT",
3636
"devDependencies": {
3737
"@commitlint/test": "8.2.0",
38-
"@commitlint/utils": "^8.3.4",
39-
"@types/lodash": "4.14.149"
38+
"@commitlint/utils": "^8.3.4"
4039
},
4140
"dependencies": {
4241
"conventional-changelog-angular": "^5.0.0",
43-
"conventional-commits-parser": "^3.0.0",
44-
"lodash": "^4.17.15"
42+
"conventional-commits-parser": "^3.0.0"
4543
}
4644
}

@commitlint/parse/src/index.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
1-
import mergeWith from 'lodash/mergeWith';
21
import {Commit, Parser, ParserOptions} from '@commitlint/types';
32

43
const {sync} = require('conventional-commits-parser');
54
const defaultChangelogOpts = require('conventional-changelog-angular');
65

7-
export default parse;
8-
9-
async function parse(
6+
export default async function parse(
107
message: string,
118
parser: Parser = sync,
129
parserOpts?: ParserOptions
1310
): Promise<Commit> {
1411
const defaultOpts = (await defaultChangelogOpts).parserOpts;
15-
const opts = mergeWith({}, defaultOpts, parserOpts, (objValue, srcValue) => {
16-
if (Array.isArray(objValue)) return srcValue;
17-
});
12+
const opts = {
13+
...defaultOpts,
14+
...(parserOpts || {})
15+
};
1816
const parsed = parser(message, opts) as Commit;
1917
parsed.raw = message;
2018
return parsed;

0 commit comments

Comments
 (0)