Skip to content

Commit

Permalink
fix(err): emit error if there is in the submodules
Browse files Browse the repository at this point in the history
Fix a variable name.
Fix the precedence of `options.transform` stream.
  • Loading branch information
stevemao committed Jun 12, 2015
1 parent 838ef57 commit ffd953b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
14 changes: 10 additions & 4 deletions index.js
@@ -1,6 +1,6 @@
'use strict';
var conventionalCommitsParser = require('conventional-commits-parser');
var conventionalcommitsWriter = require('conventional-commits-writer');
var conventionalCommitsWriter = require('conventional-commits-writer');
var fs = require('fs');
var getPkgRepo = require('get-pkg-repo');
var gitLatestSemverTag = require('git-latest-semver-tag');
Expand Down Expand Up @@ -29,7 +29,6 @@ function changelog(options, context, gitRawCommitsOpts, parserOpts, writerOpts)
append: false,
allBlocks: false,
warn: function() {},
transform: through.obj()
}, options);

var loadPreset = options.preset;
Expand Down Expand Up @@ -138,12 +137,19 @@ function changelog(options, context, gitRawCommitsOpts, parserOpts, writerOpts)
},
writerOpts
);

gitRawCommits(gitRawCommitsOpts)
.on('error', function(err) {
readable.emit('error', 'Error in git-raw-commits. ' + err);
})
.pipe(conventionalCommitsParser(parserOpts))
.on('error', function(err) {
readable.emit('error', 'Error in conventional-commits-parser. ' + err);
})
// it would be better to if `gitRawCommits` could spit out better formatted data
// so we don't need to transform here
.pipe(preset.transform || options.transform)
.pipe(conventionalcommitsWriter(context, writerOpts))
.pipe(options.transform || preset.transform || through.obj())
.pipe(conventionalCommitsWriter(context, writerOpts))
.pipe(through(function(chunk, enc, cb) {
readable.push(chunk);

Expand Down
24 changes: 24 additions & 0 deletions test/test.js
Expand Up @@ -155,4 +155,28 @@ describe('conventionalChangelog', function() {
}
});
});

it('should error if it errors in git-raw-commits', function(done) {
conventionalChangelog({}, {}, {
unknowOptions: false
})
.on('error', function(err) {
expect(err).to.include('Error in git-raw-commits.');

done();
});
});

it('should error if it errors in `options.transform`', function(done) {
conventionalChangelog({
transform: through.obj(function(chunk, enc, cb) {
cb('error');
})
})
.on('error', function(err) {
expect(err).to.include('Error in conventional-commits-parser.');

done();
});
});
});

0 comments on commit ffd953b

Please sign in to comment.