eust-w e1d3f25fa3
Some checks failed
CI / workbench (push) Has been cancelled
CI / metric-tests (push) Has been cancelled
🔧 Align development environment and record verified publications
2026-10-28 01:38:05 +08:00

25 lines
925 B
JavaScript

import { spawn } from 'node:child_process'
import { fileURLToPath } from 'node:url'
import { loadDevEnvironment } from './dev-env.mjs'
const root = fileURLToPath(new URL('../', import.meta.url))
const demo = process.argv.includes('--demo')
const env = loadDevEnvironment(root, demo)
const children = [
spawn(process.execPath, ['--import', 'tsx', 'server/index.ts'], { cwd: root, env, stdio: 'inherit' }),
spawn(process.execPath, ['node_modules/vite/bin/vite.js', '--host', '127.0.0.1'], { cwd: root, env, stdio: 'inherit' }),
]
let closing = false
function stop(code = 0) {
if (closing) return
closing = true
for (const child of children) child.kill('SIGTERM')
process.exitCode = code
}
for (const child of children) {
child.on('error', (error) => { console.error(error.message); stop(1) })
child.on('exit', (code) => stop(code || 0))
}
process.on('SIGINT', () => stop())
process.on('SIGTERM', () => stop())