Skip to content

Commit

Permalink
Adds emitting of end event on error.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelbr committed Nov 6, 2014
1 parent 57f7583 commit bd95de8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/extra_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ module.exports.onError = function (options, callback) {
reporter = notifier.notify.bind(notifier);
}
return function (error) {
report(reporter, error, options, templateOptions, callback);
var self = this;
report(reporter, error, options, templateOptions, function () {
callback.apply(self, arguments);
self.emit && self.emit('end');
});
};
};

Expand Down
15 changes: 15 additions & 0 deletions test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -610,12 +610,27 @@ describe('gulp output stream', function() {
done();
});


it('should have onError event withReporter', function(done) {
var notifier = notify.withReporter(mockGenerator);
should.exist(notifier.onError);
done();
});

it('should call end on stream', function (done) {
var onError = notify.onError({
notifier: mockGenerator(function (opts) { })
});

var stream = through.obj(function (file, enc, cb) {
this.emit('error', 'error');
cb();
});

stream.on('error', onError).on('end', done);

stream.write({});
});

it('should be limited by notifying on error if th onError-option is passed', function (done) {
var
Expand Down

0 comments on commit bd95de8

Please sign in to comment.