diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-04-12 12:06:47 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-04-12 12:06:47 -0300 |
commit | fd74ecf53ce92881460e1cf9b4c07aec76e97567 (patch) | |
tree | 8760079cc557cbba448a034690cd010ed45857c6 | |
parent | 4d21d227f230e9f82cd617f78da51561f5d08c6e (diff) |
write: live-dev-server: cleanly exit on ^C
-rw-r--r-- | src/write/build-modes/live-dev-server.js | 11 |
1 files 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; |