« Home


Detect gulp task dependency fail

There are some circumstances to detect gulp dependency task fail without exit the process. For example you want to build javascripts only after the lint task running successful, if the lint task failed, we can just ignore the error and not run the javascript build task.

var gutil = require('gulp-util');

gulp.task('lint-scripts', function () {
    // if there is an error, just throw it.
    return gulp.src(...)
        .on('error', function () {
            throw new gutil.PluginError("...", {});
    // ...

gulp.task('build-scripts', function () {
    gulp.start('lint-scripts',function (err) {
        if (err) {
        // else, just build the scripts


comments powered by Disqus