Terminate running (watch) process (gulp-4.0)

657 views Asked by At

I've implemented a task to run a server and react (reload) on changes of my source files.

export function serveDev (gulp) {
  return () => {
    const bs = browserSync.create();
    const stream =  bs.init(config.browsersync.opts);
    gulp.watch(`${config.source}/components/**/*.js`, gulp.series('scripts'));
    gulp.watch(`${config.source}/js/**/*.js`, gulp.series('scripts'));
    gulp.watch(config.browsersync.watch).on('change', bs.reload);
    return stream;
  };
}

I'm using gulp-4.0 and I'm running this task from the command line.

What's the correct implementation to terminate this task correctly when the user hits CTRL+C?

When I terminate this running task with the key-shortcut CTRL+C I get the following error:

The following tasks did not complete: serve, sync
Did you forget to signal async completion?

The task is working properly until the user hits CTRL+C. When the signal coming from CTRL+C reach the task the error described above is printed out. I would like to know how to catch or how to react properly on the termination signal coming from CTRL+C?

1

There are 1 answers

0
Elin Y. On

You can kill the background process on terminal with pkill command like:

pkill gulp