Created
May 15, 2025 07:34
-
-
Save schickling/c158f80b10a2e06939ef896f95a5bbb8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { spawn } from 'node:child_process' | |
import process from 'node:process' | |
const run = (cmd: string, args: string[], forwardStdin = true) => | |
spawn(cmd, args, { | |
shell: true, | |
stdio: [forwardStdin ? 'inherit' : 'ignore', 'inherit', 'inherit'], | |
}) | |
const processes = [ | |
// Forward stdin to allow Vite keyboard input | |
run('pnpm', ['run', 'dev:vite'], true), | |
run('pnpm', ['run', 'dev:wrangler'], false), | |
] | |
// Cleanly kill both on ^C or when either exits | |
const shutdown = () => { | |
for (const p of processes) { | |
p.kill('SIGINT') | |
} | |
} | |
process.on('SIGINT', shutdown).on('SIGTERM', shutdown) | |
for (const p of processes) { | |
p.on('exit', shutdown) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment