11

How can I cancel/stop a current running task in gulp?

My task:

gulp.task('scripts', function() {
  return gulp.src('js/main.js')
    .pipe(browserify({
        transform: [to5ify]
    }))
    .pipe(gulp.dest('./dist'));
});

It runs in a watch:

gulp.task('watch', function() {
  gulp.watch('js/**/*.js', ['scripts']);
});

If I change a js file, the task runs, thats nice. But If I change another file while the task is running, the task does not stop and restart. How can I fix this?

The task runs an average of 20s and the described case occurs frequently

Dennis
  • 397
  • 1
  • 5
  • 16

0 Answers0