Search code examples
javascriptnode.jsgulp-watch

Gulp watch quits when failing task uses streamqueue


I'm watching for changes on files like this:

gulp.watch(['./src/js/**/*', './src/templates/**/*', config.vendor.js], ['js']);

Part of my build process involves using the "angular-filesort" module (don't think this is important though). If I implement the task as follows and use plumber, when filesort fails gulp doesn't quit and "watch" will keep checking for updates which is what I want:

gulp.task('js', function() {
    gulp.src('./src/js/**/*.js').pipe(plumber()).pipe(angularFilesort());
});

However, if I wrap up this process in a streamqueue, gulp will exit when filesort fails which I don't want:

gulp.task('js', function() {
    streamqueue({
    objectMode: true
    },
    gulp.src('./src/js/**/*.js').pipe(plumber()).pipe(angularFilesort())
    )
});

How can I fix this?

Specifically, I'm doing something like this to process 3 different sets of JavaScript files then concating them:

streamqueue({
  objectMode: true
},
gulp.src(config.vendor.js),
gulp.src('./src/js/**/*.js').pipe(angularFilesort()),
gulp.src(['src/templates/**/*.html']).pipe(templateCache({
  module: mainAngularModuleName
})))
.pipe(sourcemaps.init())
.pipe(concat('app.js'))
etc.

Is there perhaps a way I can do the above without streamqueue to work around this issue?


Solution

  • I found reinstalling node and upgrading all my packages fixed this.