Skip to content

Commit b94ad00

Browse files
committed
refactor: clarify configuration merging
1 parent 38346fe commit b94ad00

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/load-parser-config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ const conventionalChangelogAngular = require('conventional-changelog-angular');
1212
* @return {Promise<Object>} a `Promise` that resolve to the `conventional-changelog-parser` options.
1313
*/
1414
module.exports = async ({preset, config, parserOpts}) => {
15-
let loadedConfig = {};
15+
let loadedConfig;
1616

1717
if (preset) {
1818
const presetPackage = `conventional-changelog-${preset.toLowerCase()}`;
1919
loadedConfig = importFrom.silent(__dirname, presetPackage) || importFrom(process.cwd(), presetPackage);
2020
} else if (config) {
2121
loadedConfig = importFrom.silent(__dirname, config) || importFrom(process.cwd(), config);
22-
} else if (!parserOpts) {
22+
} else {
2323
loadedConfig = conventionalChangelogAngular;
2424
}
2525

@@ -28,10 +28,10 @@ module.exports = async ({preset, config, parserOpts}) => {
2828
} else {
2929
loadedConfig = await loadedConfig;
3030
}
31+
3132
return mergeWith(
3233
{},
33-
loadedConfig.parserOpts,
34-
parserOpts,
34+
!preset && !config && parserOpts ? parserOpts : {...loadedConfig.parserOpts, ...parserOpts},
3535
(value, source) => (Array.isArray(value) ? source : undefined)
3636
);
3737
};

0 commit comments

Comments
 (0)