chore: fix dev script

This commit is contained in:
eneller
2026-08-02 13:06:22 +02:00
parent 954d21c05d
commit 84fdd3801a

View File

@@ -2,6 +2,8 @@
//Runs `npm run dev-bg` and listens for interrupts to execute `npm run teardown`
import { spawn } from "node:child_process";
let isShuttingDown = false;
const child = spawn("npm", ["run", "dev-bg"], {
stdio: "inherit",
shell: true,
@@ -12,12 +14,15 @@ async function teardown() {
const teardownProcess = spawn("npm", ["run", "teardown"], {
stdio: "inherit",
shell: true,
detached: true
});
await new Promise((resolve) => teardownProcess.on("exit", resolve));
}
async function shutdown(signal: any) {
if(isShuttingDown) return;
isShuttingDown = true;
child.kill(signal);
await teardown();
process.exit();
@@ -27,6 +32,5 @@ process.on("SIGINT", () => shutdown("SIGINT"));
process.on("SIGTERM", () => shutdown("SIGTERM"));
child.on("exit", async (code) => {
await teardown();
process.exit(code ?? 0);
});