nyanoblog/scripts/dev-server.js

27 lines
684 B
JavaScript
Executable File

#!/usr/bin/env node
import { spawn } from "node:child_process";
console.log("Starting development server");
const tsc = spawn("npm", ["run", "start:tsc"]);
tsc.on("exit", code => {
console.log(`tsc exited with code ${code}`);
server.kill("SIGINT");
});
tsc.stdout.on("data", console.log);
tsc.stderr.on("data", console.error);
const server = spawn("npm", ["run", "start:server"]);
server.on("exit", code => {
console.log(`web-dev-server exited with code ${code}`);
tsc.kill("SIGINT");
});
server.stderr.on("data", console.error);
process.on("SIGINT", () => {
console.log("SIGINT caught, shutting down");
server.kill("SIGINT");
tsc.kill("SIGINT");
});