Skip to content

Commit 276dcaf

Browse files
committed
feat: add extends flag
1 parent dae11d1 commit 276dcaf

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

.conventional-changelog-lintrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"extends": ["angular"]
2+
"extends": ["angular"],
3+
"preset": ["angular"]
34
}

source/cli.js

+17-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ const rules = {
3131

3232
const configuration = {
3333
// flags of string type
34-
string: ['from', 'to', 'preset'],
34+
string: ['from', 'to', 'preset', 'extends'],
35+
// flags of array type
3536
// flags of bool type
3637
boolean: ['edit', 'help', 'version', 'quiet', 'color'],
3738
// flag aliases
@@ -43,11 +44,13 @@ const configuration = {
4344
t: 'to',
4445
q: 'quiet',
4546
h: 'help',
46-
v: 'version'
47+
v: 'version',
48+
x: 'extends'
4749
},
4850
description: {
4951
color: 'toggle formatted output',
5052
edit: 'read last commit message found in ./git/COMMIT_EDITMSG',
53+
'extends': 'array of shareable configurations to extend',
5154
from: 'lower end of the commit range to lint; applies if edit=false',
5255
preset: 'conventional-changelog-preset to use for commit message parsing',
5356
to: 'upper end of the commit range to lint; applies if edit=false',
@@ -89,9 +92,20 @@ async function main(options) {
8992
.map(async commit => {
9093
const fmt = new chalk.constructor({enabled: flags.color});
9194

95+
const seed = {};
96+
if (flags.extends) {
97+
seed.extends = flags.extends.split(',');
98+
}
99+
92100
const report = lint(commit, {
93101
preset: await getPreset(flags.preset),
94-
configuration: await getConfiguration()
102+
configuration: await getConfiguration(
103+
'conventional-changelog-lint',
104+
{
105+
prefix: 'conventional-changelog-lint-config'
106+
},
107+
seed
108+
)
95109
});
96110

97111
const formatted = format(report, {

source/library/get-configuration.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function resolveExtends(config, prefix = '', key = 'extends') {
1919
// Get linting config
2020
export default (name = 'conventional-changelog-lint', settings = {
2121
prefix: 'conventional-changelog-lint-config'
22-
}) => {
23-
const config = rc(name, settings.defaults);
22+
}, seed = {}) => {
23+
const config = merge(rc(name, settings.defaults), seed);
2424
return resolveExtends(config, settings.prefix);
2525
};

0 commit comments

Comments
 (0)