skip to Main Content

I want to terminate Gulp without any further action:

gulp.task('watch', function () {
    gulp.watch('…', function quit (cb) {
        // ... totally terminate gulp here, no cleanup required, drop to OS system prompt.
    }
}

I tried throw new Error('ciao') and that would quit the watch but not the outer task loop.

2

Answers


  1. Chosen as BEST ANSWER

    Not elegant, but what works is process.exit(0);


  2. You can use the process.exit() functionality, as

    gulp.task('watch', function () {
      gulp.watch('...', function (cb) {
        // Terminate Gulp & exit the task loop
        process.exit();
      });
    });
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search