Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
909 B · 28 lines
TypeScript
at main
1234567891011121314151617181920212223242526272829import { spawn, type ChildProcess } from "node:child_process"
const npm = process.platform === "win32" ? "npm.cmd" : "npm"const server = spawn(npm, ["run", "dev:server", "--", ...process.argv.slice(2)], { stdio: "inherit" })const admin = spawn(npm, ["run", "dev:admin"], { stdio: "inherit" })const children: ChildProcess[] = [server, admin]let stopping = false
function stop(signal: NodeJS.Signals): void { if (stopping) return stopping = true for (const child of children) { if (!child.killed) child.kill(signal) }}
for (const signal of ["SIGINT", "SIGTERM"] as const) process.on(signal, () => stop(signal))
for (const child of children) { child.on("exit", (code, signal) => { if (stopping) return stopping = true for (const other of children) { if (other !== child && !other.killed) other.kill("SIGTERM") } process.exitCode = signal ? 1 : (code ?? 1) })}