From a50dd0a958ff384d99fc5a864dd76dd08f336334 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Fri, 12 Jul 2024 11:16:50 -0500 Subject: [PATCH] Small revert for #3361 --- cmd.cjs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cmd.cjs b/cmd.cjs index 77f584b09..6e7fbc877 100755 --- a/cmd.cjs +++ b/cmd.cjs @@ -99,8 +99,9 @@ const debug = require("debug")("Eleventy:cmd"); } try { - if (argv.serve) { - let shouldStartServer = true; + if (argv.serve || argv.watch) { + let shouldStartServer = argv.serve; + elev .watch() .then(() => { @@ -113,10 +114,11 @@ const debug = require("debug")("Eleventy:cmd"); // A build error occurred and we aren’t going to --serve errorHandler.fatal(e, "Eleventy CLI Error"); }); - } else if (argv.watch) { - elev.watch().catch((e) => { - // A build error occurred and we aren’t going to --watch - errorHandler.fatal(e, "Eleventy CLI Error"); + + process.on("SIGINT", async () => { + // stops the server too + await elev.stopWatch(); + process.exit(); }); } else { if (argv.to === "json") {