npm run dev:all starts the server and the site together
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Jm2auWk6RP71CjaAb4FMoG
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
f1232d5164
commit
ab999c1c43
@@ -14,7 +14,7 @@ The full rules, as transcribed from the *Duel Purpose* fanzine, are in
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
npm install
|
npm install
|
||||||
npm run dev
|
npm run dev:all # the duel server and the site together; Ctrl-C stops both
|
||||||
```
|
```
|
||||||
|
|
||||||
The hall at `/` offers two ways in: play the bot at `/play`, or duel a person. A duel between
|
The hall at `/` offers two ways in: play the bot at `/play`, or duel a person. A duel between
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite dev",
|
"dev": "vite dev",
|
||||||
|
"dev:all": "node scripts/dev-all.mjs",
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"prepare": "svelte-kit sync || echo ''",
|
"prepare": "svelte-kit sync || echo ''",
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
// The game server and the site together, for playing locally: one terminal,
|
||||||
|
// each line marked with its side, and Ctrl-C (or either one stopping) stops both.
|
||||||
|
import { spawn } from 'node:child_process';
|
||||||
|
|
||||||
|
const sides = [
|
||||||
|
['server', ['run', 'server']],
|
||||||
|
['site', ['run', 'dev', '--', ...process.argv.slice(2)]]
|
||||||
|
];
|
||||||
|
const children = sides.map(([name, args]) => {
|
||||||
|
const child = spawn('npm', args, { stdio: ['inherit', 'pipe', 'pipe'] });
|
||||||
|
for (const stream of [child.stdout, child.stderr]) {
|
||||||
|
let rest = '';
|
||||||
|
stream.on('data', (chunk) => {
|
||||||
|
const lines = (rest + chunk).split('\n');
|
||||||
|
rest = lines.pop();
|
||||||
|
for (const line of lines) console.log(`[${name}] ${line}`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
child.on('exit', (code) => stop(code ?? 0));
|
||||||
|
return child;
|
||||||
|
});
|
||||||
|
|
||||||
|
let stopping = false;
|
||||||
|
function stop(code) {
|
||||||
|
if (stopping) return;
|
||||||
|
stopping = true;
|
||||||
|
for (const c of children) if (c.exitCode === null) c.kill('SIGTERM');
|
||||||
|
process.exitCode = code;
|
||||||
|
}
|
||||||
|
process.on('SIGINT', () => stop(0));
|
||||||
|
process.on('SIGTERM', () => stop(0));
|
||||||
Reference in New Issue
Block a user