2

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?

DoK
  • 851
  • 3
  • 15
  • 31
  • Possible duplicate of [Gulp error: The following tasks did not complete: Did you forget to signal async completion?](http://stackoverflow.com/questions/36897877/gulp-error-the-following-tasks-did-not-complete-did-you-forget-to-signal-async) – Sven Schoenung Dec 27 '16 at 09:41

1 Answers1

1

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

pkill gulp
Елин Й.
  • 953
  • 10
  • 25