conventional-commits-parser
Advanced tools
Comparing version 0.0.19 to 0.1.0
'use strict'; | ||
var _ = require('lodash'); | ||
function append(src, line) { | ||
if (src) { | ||
src += '\n' + line; | ||
} else { | ||
src = line; | ||
} | ||
return src; | ||
} | ||
function parser(raw, options, regex) { | ||
@@ -102,7 +112,3 @@ if (!raw || !raw.trim()) { | ||
if (currentProcessedField) { | ||
if (otherFields[currentProcessedField]) { | ||
otherFields[currentProcessedField] += line + '\n'; | ||
} else { | ||
otherFields[currentProcessedField] = line + '\n'; | ||
} | ||
otherFields[currentProcessedField] = append(otherFields[currentProcessedField], line); | ||
@@ -120,3 +126,3 @@ return; | ||
isBody = false; | ||
footer += line + '\n'; | ||
footer = append(footer, line); | ||
@@ -127,5 +133,3 @@ var note = { | ||
}; | ||
if (note.text.trim()) { | ||
note.text += '\n'; | ||
} | ||
notes.push(note); | ||
@@ -170,3 +174,3 @@ | ||
if (referenceMatched) { | ||
footer += line + '\n'; | ||
footer = append(footer, line); | ||
@@ -178,4 +182,4 @@ return; | ||
if (continueNote) { | ||
notes[notes.length - 1].text += line + '\n'; | ||
footer += line + '\n'; | ||
notes[notes.length - 1].text = append(notes[notes.length - 1].text, line); | ||
footer = append(footer, line); | ||
@@ -187,12 +191,11 @@ return; | ||
if (isBody) { | ||
body += line + '\n'; | ||
} else { | ||
// revert this when https://github.com/jscs-dev/node-jscs/issues/1421 is solved | ||
// this is the continued footer | ||
footer += line + '\n'; | ||
body = append(body, line); | ||
} | ||
// this is the continued footer | ||
else { | ||
footer = append(footer, line); | ||
} | ||
}); | ||
body = body; | ||
footer = footer; | ||
if (!body) { | ||
@@ -219,3 +222,3 @@ body = null; | ||
var msg = _.merge(headerParts, { | ||
header: header + '\n', | ||
header: header, | ||
body: body, | ||
@@ -222,0 +225,0 @@ footer: footer, |
{ | ||
"name": "conventional-commits-parser", | ||
"version": "0.0.19", | ||
"version": "0.1.0", | ||
"description": "Parse raw conventional commits", | ||
@@ -34,3 +34,3 @@ "homepage": "https://github.com/stevemao/conventional-commits-parser", | ||
"istanbul": "^0.3.6", | ||
"jscs": "^1.13.1", | ||
"jscs": "^2.0.0", | ||
"jshint": "^2.7.0", | ||
@@ -37,0 +37,0 @@ "mocha": "*" |
@@ -228,3 +228,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] | ||
{"type":"fix","scope":"title","subject":"a title is fixed","header":"fix(title): a title is fixed\n","body":null,"footer":null,"notes":[],"references":[],"revert":null} | ||
{"type":"fix","scope":"title","subject":"a title is fixed","header":"fix(title): a title is fixed","body":null,"footer":null,"notes":[],"references":[],"revert":null} | ||
``` | ||
@@ -259,3 +259,3 @@ | ||
[ | ||
{"type":"feat","scope":"ngMessages","subject":"provide support for dynamic message resolution","header":"feat(ngMessages): provide support for dynamic message resolution\n","body":"Prior to this fix it was impossible to apply a binding to a the ngMessage directive to represent the name of the error.\n","footer":"BREAKING CHANGE: The `ngMessagesInclude` attribute is now its own directive and that must be placed as a **child** element within the element with the ngMessages directive.\nCloses #10036\nCloses #9338\n","notes":[{"title":"BREAKING CHANGE","text":"The `ngMessagesInclude` attribute is now its own directive and that must be placed as a **child** element within the element with the ngMessages directive.\n"}],"references":[{"action":"Closes","owner":null,"repository":null,"issue":"10036","raw":"#10036"},{"action":"Closes","owner":null,"repository":null,"issue":"9338","raw":"#9338"}],"revert":null} | ||
{"type":"feat","scope":"ngMessages","subject":"provide support for dynamic message resolution","header":"feat(ngMessages): provide support for dynamic message resolution","body":"Prior to this fix it was impossible to apply a binding to a the ngMessage directive to represent the name of the error.","footer":"BREAKING CHANGE: The `ngMessagesInclude` attribute is now its own directive and that must be placed as a **child** element within the element with the ngMessages directive.\nCloses #10036\nCloses #9338","notes":[{"title":"BREAKING CHANGE","text":"The `ngMessagesInclude` attribute is now its own directive and that must be placed as a **child** element within the element with the ngMessages directive."}],"references":[{"action":"Closes","owner":null,"repository":null,"issue":"10036","raw":"#10036"},{"action":"Closes","owner":null,"repository":null,"issue":"9338","raw":"#9338"}],"revert":null} | ||
] | ||
@@ -286,5 +286,5 @@ ``` | ||
[ | ||
{"type":"docs","scope":"ngMessageExp","subject":"split ngMessage docs up to show its alias more clearly","header":"docs(ngMessageExp): split ngMessage docs up to show its alias more clearly\n","body":null,"footer":null,"notes":[],"references":[],"revert":null} | ||
{"type":"docs","scope":"ngMessageExp","subject":"split ngMessage docs up to show its alias more clearly","header":"docs(ngMessageExp): split ngMessage docs up to show its alias more clearly","body":null,"footer":null,"notes":[],"references":[],"revert":null} | ||
, | ||
{"type":"fix","scope":"$animate","subject":"applyStyles from options on leave","header":"fix($animate): applyStyles from options on leave\n","body":null,"footer":"Closes #10068\n","notes":[],"references":[{"action":"Closes","owner":null,"repository":null,"issue":"10068","raw":"#10068"}],"revert":null} | ||
{"type":"fix","scope":"$animate","subject":"applyStyles from options on leave","header":"fix($animate): applyStyles from options on leave","body":null,"footer":"Closes #10068","notes":[],"references":[{"action":"Closes","owner":null,"repository":null,"issue":"10068","raw":"#10068"}],"revert":null} | ||
] | ||
@@ -291,0 +291,0 @@ ``` |
@@ -84,3 +84,3 @@ 'use strict'; | ||
expect(chunk.toString()).to.include('"references":[{"action":"Close","owner":null,"repository":null,"issue":"10036","raw":"#10036"},{"action":"fix","owner":null,"repository":null,"issue":"9338","raw":"#9338"}]'); | ||
expect(chunk.toString()).to.include('"notes":[{"title":"BREAKING NEWS","text":"A lot of changes!\\n"}]'); | ||
expect(chunk.toString()).to.include('"notes":[{"title":"BREAKING NEWS","text":"A lot of changes!"}]'); | ||
@@ -87,0 +87,0 @@ done(); |
@@ -45,12 +45,12 @@ 'use strict'; | ||
if (i === 0) { | ||
expect(chunk.header).to.equal('feat(ng-list): Allow custom separator\n'); | ||
expect(chunk.header).to.equal('feat(ng-list): Allow custom separator'); | ||
} else if (i === 1) { | ||
expect(chunk.notes).to.eql([{ | ||
title: 'BREAKING CHANGE', | ||
text: 'some breaking change\n' | ||
text: 'some breaking change' | ||
}]); | ||
} else if (i === 2) { | ||
expect(chunk.header).to.equal('fix(zzz): Very cool commit\n'); | ||
expect(chunk.header).to.equal('fix(zzz): Very cool commit'); | ||
} else if (i === 3) { | ||
expect(chunk.header).to.equal('chore(scope with spaces): some chore\n'); | ||
expect(chunk.header).to.equal('chore(scope with spaces): some chore'); | ||
} else if (i === 4) { | ||
@@ -186,3 +186,3 @@ expect(chunk.revert).to.eql({ | ||
title: 'BREAKING CHANGES', | ||
text: 'some breaking changes\n' | ||
text: 'some breaking changes' | ||
}); | ||
@@ -245,7 +245,7 @@ } | ||
title: 'BREAKING CHANGES', | ||
text: 'some breaking changes\n' | ||
text: 'some breaking changes' | ||
}); | ||
} else if (i === 2) { | ||
expect(chunk.header).to.equal('blabla\n'); | ||
expect(chunk.hash).to.equal('9b1aff905b638aa274a5fc8f88662df446d374bd\n'); | ||
expect(chunk.header).to.equal('blabla'); | ||
expect(chunk.hash).to.equal('9b1aff905b638aa274a5fc8f88662df446d374bd'); | ||
} else if (i === 3) { | ||
@@ -271,5 +271,5 @@ expect(chunk.revert.header).to.equal('throw an error if a callback is passed to animate methods'); | ||
expect(result.header).to.equal('feat(ng-list): Allow custom separator\n'); | ||
expect(result.footer).to.equal('Closes #123\nCloses #25\nFixes #33\n'); | ||
expect(result.header).to.equal('feat(ng-list): Allow custom separator'); | ||
expect(result.footer).to.equal('Closes #123\nCloses #25\nFixes #33'); | ||
}); | ||
}); |
@@ -118,3 +118,3 @@ 'use strict'; | ||
it('should parse header', function() { | ||
expect(msg.header).to.equal('feat(scope): broadcast $destroy event on scope destruction\n'); | ||
expect(msg.header).to.equal('feat(scope): broadcast $destroy event on scope destruction'); | ||
}); | ||
@@ -186,3 +186,3 @@ | ||
'perf testing shows that in chrome this change adds 5-15% overhead\n' + | ||
'when destroying 10k nested scopes where each scope has a $destroy listener\n'); | ||
'when destroying 10k nested scopes where each scope has a $destroy listener'); | ||
}); | ||
@@ -206,3 +206,3 @@ | ||
'handle #33, Closes #100, Handled #3 kills repo#77\n' + | ||
'kills stevemao/conventional-commits-parser#1\n' | ||
'kills stevemao/conventional-commits-parser#1' | ||
); | ||
@@ -218,3 +218,3 @@ }); | ||
title: 'BREAKING AMEND', | ||
text: 'some breaking change\n' | ||
text: 'some breaking change' | ||
}); | ||
@@ -226,3 +226,3 @@ }); | ||
title: 'BREAKING AMEND', | ||
text: 'some breaking change\nsome other breaking change\n' | ||
text: 'some breaking change\nsome other breaking change' | ||
}); | ||
@@ -301,3 +301,3 @@ }); | ||
expect(msg.footer).to.equal('Kills #1, #123\nwhat\nkilled #25\nhandle #33, Closes #100, Handled #3\nother\n'); | ||
expect(msg.footer).to.equal('Kills #1, #123\nwhat\nkilled #25\nhandle #33, Closes #100, Handled #3\nother'); | ||
}); | ||
@@ -317,3 +317,3 @@ | ||
title: 'BREAKING AMEND', | ||
text: 'some breaking change\n' | ||
text: 'some breaking change' | ||
}); | ||
@@ -333,3 +333,3 @@ expect(msg.references).to.eql([{ | ||
}]); | ||
expect(msg.footer).to.equal('Kills #1, #123\nBREAKING AMEND: some breaking change\n'); | ||
expect(msg.footer).to.equal('Kills #1, #123\nBREAKING AMEND: some breaking change'); | ||
}); | ||
@@ -349,3 +349,3 @@ | ||
title: 'BREAKING AMEND', | ||
text: 'some breaking change\nsome other breaking change\n' | ||
text: 'some breaking change\nsome other breaking change' | ||
}); | ||
@@ -365,3 +365,3 @@ expect(msg.references).to.eql([{ | ||
}]); | ||
expect(msg.footer).to.equal('Kills #1, #123\nBREAKING AMEND: some breaking change\nsome other breaking change\n'); | ||
expect(msg.footer).to.equal('Kills #1, #123\nBREAKING AMEND: some breaking change\nsome other breaking change'); | ||
}); | ||
@@ -382,3 +382,3 @@ | ||
title: 'BREAKING AMEND', | ||
text: 'some breaking change\n' | ||
text: 'some breaking change' | ||
}); | ||
@@ -398,3 +398,3 @@ expect(msg.references).to.eql([{ | ||
}]); | ||
expect(msg.footer).to.equal('Kills #1, #123\nother\nBREAKING AMEND: some breaking change\n'); | ||
expect(msg.footer).to.equal('Kills #1, #123\nother\nBREAKING AMEND: some breaking change'); | ||
}); | ||
@@ -425,3 +425,3 @@ }); | ||
expect(msg.hash).to.equal('9b1aff905b638aa274a5fc8f88662df446d374bd\n'); | ||
expect(msg.hash).to.equal('9b1aff905b638aa274a5fc8f88662df446d374bd'); | ||
}); | ||
@@ -454,3 +454,3 @@ | ||
'Also it should continue if one file cannot be found.\n' + | ||
'Tests are added for these\n'); | ||
'Tests are added for these'); | ||
}); | ||
@@ -481,4 +481,4 @@ | ||
expect(msg.committerName).to.equal('Steve Mao\n'); | ||
expect(msg[' committerEmail']).to.equal('test@github.com\n'); | ||
expect(msg.committerName).to.equal('Steve Mao'); | ||
expect(msg[' committerEmail']).to.equal('test@github.com'); | ||
}); | ||
@@ -485,0 +485,0 @@ }); |
59366
1384