Skip to content

Commit

Permalink
feat: add extends flag
Browse files Browse the repository at this point in the history
  • Loading branch information
marionebl committed Feb 14, 2016
1 parent dae11d1 commit 276dcaf
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .conventional-changelog-lintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"extends": ["angular"]
"extends": ["angular"],
"preset": ["angular"]
}
20 changes: 17 additions & 3 deletions source/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ const rules = {

const configuration = {
// flags of string type
string: ['from', 'to', 'preset'],
string: ['from', 'to', 'preset', 'extends'],
// flags of array type
// flags of bool type
boolean: ['edit', 'help', 'version', 'quiet', 'color'],
// flag aliases
Expand All @@ -43,11 +44,13 @@ const configuration = {
t: 'to',
q: 'quiet',
h: 'help',
v: 'version'
v: 'version',
x: 'extends'
},
description: {
color: 'toggle formatted output',
edit: 'read last commit message found in ./git/COMMIT_EDITMSG',
'extends': 'array of shareable configurations to extend',
from: 'lower end of the commit range to lint; applies if edit=false',
preset: 'conventional-changelog-preset to use for commit message parsing',
to: 'upper end of the commit range to lint; applies if edit=false',
Expand Down Expand Up @@ -89,9 +92,20 @@ async function main(options) {
.map(async commit => {
const fmt = new chalk.constructor({enabled: flags.color});

const seed = {};
if (flags.extends) {
seed.extends = flags.extends.split(',');
}

const report = lint(commit, {
preset: await getPreset(flags.preset),
configuration: await getConfiguration()
configuration: await getConfiguration(
'conventional-changelog-lint',
{
prefix: 'conventional-changelog-lint-config'
},
seed
)
});

const formatted = format(report, {
Expand Down
4 changes: 2 additions & 2 deletions source/library/get-configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function resolveExtends(config, prefix = '', key = 'extends') {
// Get linting config
export default (name = 'conventional-changelog-lint', settings = {
prefix: 'conventional-changelog-lint-config'
}) => {
const config = rc(name, settings.defaults);
}, seed = {}) => {
const config = merge(rc(name, settings.defaults), seed);
return resolveExtends(config, settings.prefix);
};

0 comments on commit 276dcaf

Please sign in to comment.