Gulp returns 0 when tasks fail

后端 未结 6 1307
庸人自扰
庸人自扰 2021-01-01 09:09

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

6条回答
  •  没有蜡笔的小新
    2021-01-01 09:33

    Similar to Andy Piper answer above, I have found this module stream-combiner2 to be useful when running a sequence of tasks to ensure and exit code is emitted if there is an error somewhere. Can be used something like this

    var combiner = require('stream-combiner2');
    
    var tasks = combiner.obj([
        gulp.src(files),
        task1(options),
        task2(options),
        gulp.dest('path/to/dest')
    ]);
    
    tasks.on('error', function () {
        process.exit(1)
    });
    

提交回复
热议问题