Skip to content

Commit

Permalink
Print mocha output immediately, not when process finished (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
mamont authored and sindresorhus committed Mar 7, 2017
1 parent 12d44db commit bf30380
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,19 @@ module.exports = opts => {
}

function flush(done) {
execa('mocha', files.concat(args))
.then(result => {
if (!opts.suppress) {
process.stdout.write(result.stdout);
}

// For testing
this.emit('_result', result);

done();
})
.catch(err => {
this.emit('error', new gutil.PluginError('gulp-mocha', err));
done();
});
let proc = execa('mocha', files.concat(args));
proc.then(result => {
this.emit('_result', result);
done();
})
.catch(err => {
this.emit('error', new gutil.PluginError('gulp-mocha', err));
done();
});

if (!opts.suppress) {
proc.stdout.pipe(process.stdout);
}
}

return through.obj(aggregate, flush);
Expand Down

0 comments on commit bf30380

Please sign in to comment.