From fd74ecf53ce92881460e1cf9b4c07aec76e97567 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 12 Apr 2024 12:06:47 -0300 Subject: write: live-dev-server: cleanly exit on ^C --- src/write/build-modes/live-dev-server.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/write/build-modes/live-dev-server.js b/src/write/build-modes/live-dev-server.js index a2a84a89..24e18320 100644 --- a/src/write/build-modes/live-dev-server.js +++ b/src/write/build-modes/live-dev-server.js @@ -474,10 +474,15 @@ export async function go({ if (skipServing) { logInfo`Ready to serve! But --skip-serving was passed, so all done.`; } else { - server.listen(port, host); + process.on('SIGINT', () => { + process.stdout.write('\n'); + server.close(); + }); - // Just keep going... forever!!! - await new Promise(() => {}); + await new Promise(resolve => { + server.listen(port, host); + server.on('close', () => resolve()); + }); } return true; -- cgit 1.3.0-6-gf8a5