Skip to content
This repository has been archived by the owner on Feb 5, 2018. It is now read-only.

Commit

Permalink
fix(parser): it returns null if there is no header
Browse files Browse the repository at this point in the history
  • Loading branch information
stevemao committed Mar 9, 2015
1 parent 436c8f8 commit b6640b3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ function processFile(fileIndex) {
fs.createReadStream(filePath)
.on('error', function(err) {
console.warn('Failed to read file ' + filePath + '\n' + err);
if(++fileIndex < length) {
if (++fileIndex < length) {
processFile(fileIndex);
}
})
.pipe(split(separator))
.pipe(conventionalCommitsParser(cli.flags))
.pipe(JSONStream.stringify())
.on('end', function() {
if(++fileIndex < length) {
if (++fileIndex < length) {
processFile(fileIndex);
}
})
Expand Down
4 changes: 4 additions & 0 deletions lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ function parser(raw, options) {
lines.splice(0, 2);
}

if (!msg.header) {
return null;
}

match = msg.header.match(options.headerPattern);
if (!match || !match[1] || !match[3]) {
return null;
Expand Down
4 changes: 4 additions & 0 deletions test/parser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ describe('parseRawCommit', function() {
expect(parser('bla bla', options)).to.equal(null);
});

it('should returns null if there is no header', function() {
expect(parser('056f5827de86cace1f282c8e3f1cccc952fcad2e', options)).to.equal(null);
});

it('should parse header', function() {
expect(msg.header).to.equal('feat(scope): broadcast $destroy event on scope destruction');
});
Expand Down

0 comments on commit b6640b3

Please sign in to comment.