conventional-commits-parser
Advanced tools
Comparing version 0.0.16 to 0.0.17
12
cli.js
@@ -37,4 +37,6 @@ #!/usr/bin/env node | ||
' -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' | ||
' -r, --reference-actions Comma separated keywords that used to reference issues', | ||
' -i, --issue-prefixes Comma separated prefixes of an issue', | ||
' -n, --note-keywords Comma separated keywords for important notes', | ||
' -f, --field-pattern Regex to match other fields' | ||
].join('\n') | ||
@@ -45,4 +47,6 @@ }, { | ||
c: 'headerCorrespondence', | ||
r: 'referenceKeywords', | ||
n: 'noteKeywords' | ||
r: 'referenceActions', | ||
i: 'issuePrefixes', | ||
n: 'noteKeywords', | ||
f: 'fieldPattern' | ||
} | ||
@@ -49,0 +53,0 @@ }); |
11
index.js
@@ -11,3 +11,3 @@ 'use strict'; | ||
headerCorrespondence: ['type', 'scope', 'subject'], | ||
referenceKeywords: [ | ||
referenceActions: [ | ||
'close', | ||
@@ -23,2 +23,3 @@ 'closes', | ||
], | ||
issuePrefixes: ['#'], | ||
noteKeywords: ['BREAKING CHANGE'], | ||
@@ -40,6 +41,10 @@ fieldPattern: /^-(.*?)-$/, | ||
if (typeof options.referenceKeywords === 'string') { | ||
options.referenceKeywords = options.referenceKeywords.split(','); | ||
if (typeof options.referenceActions === 'string') { | ||
options.referenceActions = options.referenceActions.split(','); | ||
} | ||
if (typeof options.issuePrefixes === 'string') { | ||
options.issuePrefixes = options.issuePrefixes.split(','); | ||
} | ||
if (typeof options.noteKeywords === 'string') { | ||
@@ -46,0 +51,0 @@ options.noteKeywords = options.noteKeywords.split(','); |
'use strict'; | ||
var reNomatch = /(?!.*)/; | ||
var reReferenceParts = /(?:.*?)??\s*(\S*?)??(?:gh-|#)(\d+)/gi; | ||
@@ -25,15 +24,24 @@ function join(array, joiner) { | ||
function getReferencesRegex(referenceKeywords) { | ||
if (!referenceKeywords) { | ||
function getReferencePartsRegex(issuePrefixes) { | ||
if (!issuePrefixes) { | ||
return reNomatch; | ||
} | ||
var joinedKeywords = join(referenceKeywords, '|'); | ||
return new RegExp('(' + joinedKeywords + ')(?:\\s+(.*?))(?=(?:' + joinedKeywords + ')|$)', 'ig'); | ||
return new RegExp('(?:.*?)??\\s*(\\S*?)??(?:' + join(issuePrefixes, '|') + ')(\\d+)', 'gi'); | ||
} | ||
function getReferencesRegex(referenceActions) { | ||
if (!referenceActions) { | ||
return reNomatch; | ||
} | ||
var joinedKeywords = join(referenceActions, '|'); | ||
return new RegExp('(' + joinedKeywords + ')(?:\\s+(.*?))(?=(?:' + joinedKeywords + ')|$)', 'gi'); | ||
} | ||
module.exports = function(options) { | ||
options = options || {}; | ||
var reNotes = getNotesRegex(options.noteKeywords); | ||
var reReferences = getReferencesRegex(options.referenceKeywords); | ||
var reReferenceParts = getReferencePartsRegex(options.issuePrefixes); | ||
var reReferences = getReferencesRegex(options.referenceActions); | ||
@@ -40,0 +48,0 @@ return { |
{ | ||
"name": "conventional-commits-parser", | ||
"version": "0.0.16", | ||
"version": "0.0.17", | ||
"description": "Parse raw conventional commits", | ||
@@ -27,6 +27,6 @@ "homepage": "https://github.com/stevemao/conventional-commits-parser", | ||
"split": "^1.0.0", | ||
"through2": "^0.6.3" | ||
"through2": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"chai": "^2.1.0", | ||
"chai": "^3.0.0", | ||
"concat-stream": "^1.4.7", | ||
@@ -33,0 +33,0 @@ "coveralls": "^2.11.2", |
@@ -117,3 +117,3 @@ # [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage Status][coveralls-image]][coveralls-url] | ||
##### referenceKeywords | ||
##### referenceActions | ||
@@ -133,4 +133,10 @@ Type: `array` of `string` or `string` Default: | ||
Keywords for references. This value is case **insensitive**. If it's a `string` it will be converted to an `array` separated by a comma. | ||
Keywords to reference an issue. This value is case **insensitive**. If it's a `string` it will be converted to an `array` separated by a comma. | ||
##### issuePrefixes | ||
Type: `array` of `string` or `string` Default: `['#']` | ||
The prefixes of an issue. EG: In `gh-123` `gh-` is the prefix. | ||
##### noteKeywords | ||
@@ -137,0 +143,0 @@ |
@@ -69,3 +69,3 @@ 'use strict'; | ||
it('should work with options', function(done) { | ||
var cp = spawn(cliPath, ['test/fixtures/log3.txt', '-p', '^(\\w*)(?:\\(([:\\w\\$\\.\\-\\* ]*)\\))?\\: (.*)$', '--reference-keywords', 'close, fix', '-n', 'BREAKING NEWS', '--headerCorrespondence', 'scope, type,subject '], { | ||
var cp = spawn(cliPath, ['test/fixtures/log3.txt', '-p', '^(\\w*)(?:\\(([:\\w\\$\\.\\-\\* ]*)\\))?\\: (.*)$', '--reference-actions', 'close, fix', '-n', 'BREAKING NEWS', '--headerCorrespondence', 'scope, type,subject '], { | ||
stdio: [process.stdin, null, null] | ||
@@ -72,0 +72,0 @@ }); |
@@ -146,3 +146,3 @@ 'use strict'; | ||
noteKeywords: ['BREAKING CHANGES'], | ||
referenceKeywords: ['fix'] | ||
referenceActions: ['fix'] | ||
})) | ||
@@ -198,4 +198,5 @@ .pipe(through.obj(function(chunk, enc, cb) { | ||
headerCorrespondence: 'subject,type, scope,', | ||
issuePrefixes: '#', | ||
noteKeywords: 'BREAKING CHANGES', | ||
referenceKeywords: 'fix' | ||
referenceActions: 'fix' | ||
})) | ||
@@ -202,0 +203,0 @@ .pipe(through.obj(function(chunk, enc, cb) { |
@@ -19,3 +19,4 @@ 'use strict'; | ||
var reNotes = regex({ | ||
noteKeywords: [' Breaking News', 'Breaking Change ', '', ' Breaking SOLUTION ', ' '] | ||
noteKeywords: [' Breaking News', 'Breaking Change ', '', ' Breaking SOLUTION ', ' '], | ||
issuePrefixes: ['#'] | ||
}).notes; | ||
@@ -32,3 +33,4 @@ var match = 'Breaking News: This is so important.'.match(reNotes); | ||
var reReferences = regex({ | ||
referenceKeywords: ['Closes'] | ||
referenceActions: ['Closes'], | ||
issuePrefixes: ['#'] | ||
}).references; | ||
@@ -42,3 +44,4 @@ var match = reReferences.exec('closes #1'); | ||
var reReferences = regex({ | ||
referenceKeywords: ['Closes'] | ||
referenceActions: ['Closes'], | ||
issuePrefixes: ['#'] | ||
}).references; | ||
@@ -52,3 +55,4 @@ var match = reReferences.exec('ClOsEs #1'); | ||
var reReferences = regex({ | ||
referenceKeywords: ['Close'] | ||
referenceActions: ['Close'], | ||
issuePrefixes: ['#'] | ||
}).references; | ||
@@ -61,3 +65,4 @@ var match = reReferences.exec('Closes #1'); | ||
var reReferences = regex({ | ||
referenceKeywords: [' Closes', 'amends', 'fixes'] | ||
referenceActions: [' Closes', 'amends', 'fixes'], | ||
issuePrefixes: ['#'] | ||
}).references; | ||
@@ -71,3 +76,4 @@ var match = reReferences.exec('amends #1'); | ||
var reReferences = regex({ | ||
referenceKeywords: ['Closes', 'amends'] | ||
referenceActions: ['Closes', 'amends'], | ||
issuePrefixes: ['#'] | ||
}).references; | ||
@@ -90,3 +96,4 @@ var string = 'Closes #1 amends #2; closes bug #4'; | ||
var reReferences = regex({ | ||
referenceKeywords: [' Closes', 'amends ', '', ' fixes ', ' '] | ||
referenceActions: [' Closes', 'amends ', '', ' fixes ', ' '], | ||
issuePrefixes: ['#'] | ||
}).references; | ||
@@ -99,3 +106,5 @@ var match = 'closes #1, amends #2, fixes #3'.match(reReferences); | ||
describe('referenceParts', function() { | ||
var reReferenceParts = regex().referenceParts; | ||
var reReferenceParts = regex({ | ||
issuePrefixes: ['#'] | ||
}).referenceParts; | ||
@@ -149,3 +158,28 @@ afterEach(function() { | ||
}); | ||
it('should match issues with customized prefix', function() { | ||
var string = 'closes gh-1, amends #2, fixes prefix-3'; | ||
reReferenceParts = regex({ | ||
issuePrefixes: ['gh-', 'prefix-'] | ||
}).referenceParts; | ||
var match = reReferenceParts.exec(string); | ||
expect(match[0]).to.equal('closes gh-1'); | ||
expect(match[1]).to.equal(undefined); | ||
expect(match[2]).to.equal('1'); | ||
match = reReferenceParts.exec(string); | ||
expect(match[0]).to.equal(', amends #2, fixes prefix-3'); | ||
expect(match[1]).to.equal(undefined); | ||
expect(match[2]).to.equal('3'); | ||
}); | ||
it('should match nothing if there is no customized prefix', function() { | ||
var string = 'closes gh-1, amends #2, fixes prefix-3'; | ||
reReferenceParts = regex().referenceParts; | ||
var match = reReferenceParts.exec(string); | ||
expect(match).to.equal(null); | ||
}); | ||
}); | ||
}); |
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
52631
1204
259
+ Addedisarray@1.0.0(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedreadable-stream@2.3.8(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedstring_decoder@1.1.1(transitive)
+ Addedthrough2@2.0.5(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
- Removedisarray@0.0.1(transitive)
- Removedreadable-stream@1.0.34(transitive)
- Removedstring_decoder@0.10.31(transitive)
- Removedthrough2@0.6.5(transitive)
Updatedthrough2@^2.0.0