#!/usr/bin/env node // dev: 同时跑 dev:backend(air 热加载 control-plane)与 dev:frontend(vite HMR)。 // Ctrl-C 结束两个子进程。 import { spawn } from "node:child_process"; import path from "node:path"; import { fileURLToPath } from "node:url"; const root = path.dirname(path.dirname(fileURLToPath(import.meta.url))); const pnpm = process.env.npm_execpath || "pnpm"; const procs = [ spawn(pnpm, ["run", "dev:backend"], { cwd: root, stdio: "inherit" }), spawn(pnpm, ["run", "dev:frontend"], { cwd: root, stdio: "inherit" }), ]; for (const signal of ["SIGINT", "SIGTERM"]) { process.on(signal, () => { for (const p of procs) p.kill(signal); }); } let remaining = procs.length; for (const p of procs) { p.on("exit", (code) => { if (--remaining === 0) process.exit(code ?? 0); }); }