How to pass SIGINT to multiple parallel Gulp watchers?

Viewed 11

I have a Gulp task that should launch several watch tasks, and output all of the stdout messages to the same console. I would like all of the tasks to terminate on SIGINT (CTRL-C in the terminal).

One task uses gulp.watch (a SCSS watcher) and terminates correctly. The other three tasks use a watcher that's built-into the CLI executable and available as a command line argument. I'm using gulp-run-command, which wraps spawn. The other CLI watchers include:

  • jest --watch
  • webpack with { watch: true } set in Webpack config
  • eleventy --watch --serve --incremental for static HTML generation

I have each of the four watchers defined in their own tasks, and then a watch task that runs all four in parallel. The watch task launches all four watcher tasks and directs their output correctly to the console, but ending CTRL-C to the shell it's launched in only kills the Gulp watch task and the task that uses gulp.watch (the SCSS task).

It seems like the eleventy static HTML generator watch task also is killed on CTRL-C, though I'm not sure why. Right now I'm having to remember to ps -ax | grep webpack and then kill -9 <PID>, etc., to end the other watchers.

Is there a way to get CTRL-C to kill all of my watchers at once?

0 Answers
Related