conventional-commits-parser
Advanced tools
Comparing version 0.0.12 to 0.0.13
10
cli.js
@@ -33,6 +33,7 @@ #!/usr/bin/env node | ||
'Options', | ||
'-m, --max-subject-length Maximum subject length', | ||
'-p, --header-pattern Regex to match header pattern', | ||
'-r, --reference-keywords Comma separated keywords that used to reference issues', | ||
'-n, --note-keywords Comma separated keywords for important notes' | ||
'-m, --max-subject-length Maximum subject length', | ||
'-p, --header-pattern Regex to match header pattern', | ||
'-c, --header-correspondence Comma separated parts used to define what capturing group of `headerPattern` captures what', | ||
'-r, --reference-keywords Comma separated keywords that used to reference issues', | ||
'-n, --note-keywords Comma separated keywords for important notes' | ||
].join('\n') | ||
@@ -43,2 +44,3 @@ }, { | ||
p: 'headerPattern', | ||
c: 'headerCorrespondence', | ||
r: 'referenceKeywords', | ||
@@ -45,0 +47,0 @@ n: 'noteKeywords' |
@@ -20,2 +20,6 @@ 'use strict'; | ||
} | ||
if (typeof options.headerCorrespondence === 'string') { | ||
options.headerCorrespondence = options.headerCorrespondence.split(','); | ||
} | ||
} | ||
@@ -22,0 +26,0 @@ |
@@ -20,4 +20,16 @@ 'use strict'; | ||
function getHeadCorrespondence(correspondence) { | ||
return _.indexOf(options.headerCorrespondence, correspondence) + 1; | ||
function getHeadCorrespondence(part) { | ||
var headerCorrespondence = options.headerCorrespondence | ||
.map(function(val) { | ||
return val.trim(); | ||
}) | ||
.filter(function(val) { | ||
return val.length; | ||
}); | ||
var index = _.indexOf(headerCorrespondence, part) + 1; | ||
if (index === 0) { | ||
throw new TypeError('Expected options.headerCorrespondence to only contain "type" "scope" or "subject"'); | ||
} | ||
return index; | ||
} | ||
@@ -24,0 +36,0 @@ |
{ | ||
"name": "conventional-commits-parser", | ||
"version": "0.0.12", | ||
"version": "0.0.13", | ||
"description": "Parse raw conventional commits", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/stevemao/conventional-commits-parser", |
@@ -126,3 +126,3 @@ # [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage Status][coverall-image]][coverall-url] | ||
Used to define what capturing group captures what. The order of the array should correspond to the order of `headerPattern`'s capturing group. | ||
Used to define what capturing group of `headerPattern` captures what header part. The order of the array should correspond to the order of `headerPattern`'s capturing group. If it's a `string` it will be converted to an `array` separated by a comma. | ||
@@ -129,0 +129,0 @@ ##### referenceKeywords |
@@ -191,9 +191,10 @@ 'use strict'; | ||
referenceKeywords: 'fix', | ||
noteKeywords: 'BREAKING CHANGES' | ||
noteKeywords: 'BREAKING CHANGES', | ||
headerCorrespondence: 'subject,type, scope,' | ||
})) | ||
.pipe(through.obj(function(chunk, enc, cb) { | ||
if (--length === 1) { | ||
expect(chunk.type).to.equal('feat'); | ||
expect(chunk.scope).to.equal('ng-list'); | ||
expect(chunk.subject).to.equal('Allow custom separator'); | ||
expect(chunk.type).to.equal('ng-list'); | ||
expect(chunk.scope).to.equal('Allow custom separator'); | ||
expect(chunk.subject).to.equal('feat'); | ||
expect(chunk.references).to.eql([{ | ||
@@ -211,5 +212,5 @@ action: 'Fix', | ||
} else { | ||
expect(chunk.type).to.equal('fix'); | ||
expect(chunk.scope).to.equal('ng-list'); | ||
expect(chunk.subject).to.equal('Another custom separator'); | ||
expect(chunk.type).to.equal('ng-list'); | ||
expect(chunk.scope).to.equal('Another custom separator'); | ||
expect(chunk.subject).to.equal('fix'); | ||
expect(chunk.notes[0]).to.eql({ | ||
@@ -216,0 +217,0 @@ title: 'BREAKING CHANGES', |
@@ -199,2 +199,18 @@ 'use strict'; | ||
}); | ||
it('should throw if headerCorrespondence contains illegal value', function() { | ||
expect(function() { | ||
parser('scope(my subject): fix this', { | ||
maxSubjectLength: 80, | ||
headerPattern: /^(\w*)(?:\(([\w\$\.\-\* ]*)\))?\: (.*)$/, | ||
headerCorrespondence: ['scop', 'subject', 'type'], | ||
referenceKeywords: [ | ||
'kill' | ||
], | ||
noteKeywords: [ | ||
'BREAKING AMEND' | ||
] | ||
}); | ||
}).to.throw('Expected options.headerCorrespondence can only contain "type" "scope" or "subject"'); | ||
}); | ||
}); | ||
@@ -201,0 +217,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
48388
1032