16 lines
553 B
TypeScript
16 lines
553 B
TypeScript
const children = [
|
|
Bun.spawn(["bun", "--watch", "index.ts"], { stdout: "inherit", stderr: "inherit", env: { ...process.env, NODE_ENV: "development" } }),
|
|
Bun.spawn(["bun", "run", "--bun", "vite"], { stdout: "inherit", stderr: "inherit" }),
|
|
];
|
|
let stopping = false;
|
|
function stop() {
|
|
if (stopping) return;
|
|
stopping = true;
|
|
children.forEach(child => child.kill());
|
|
}
|
|
process.on("SIGINT", stop);
|
|
process.on("SIGTERM", stop);
|
|
await Promise.race(children.map(child => child.exited));
|
|
stop();
|
|
await Promise.all(children.map(child => child.exited));
|