I\'m using Gulp in my small project in order to run tests and lint my code. When any of those tasks fail, Gulp always exits with return code 0. If I run jshint by hand, it e
@robrich is right, you have to keep track of exit codes yourself, but there's no need for a forceful approach. The process
global is an EventEmitter
which you can bind your exit function to.
var exitCode = 0
gulp.task('test', function (done) {
return require('child_process')
.spawn('npm', ['test'], {stdio: 'pipe'})
.on('close', function (code, signal) {
if (code) exitCode = code
done()
})
})
gulp.on('err', function (err) {
process.emit('exit') // or throw err
})
process.on('exit', function () {
process.nextTick(function () {
process.exit(exitCode)
})
})