singularity-forge/scripts/dev.js
Mikael Hugo d73a73d7f3 chore: node 24 native APIs, import.meta.dirname, parsers rename, dep updates
- Replace fileURLToPath(import.meta.url) with import.meta.dirname across
  scripts and extensions
- Rename parsers-legacy.ts → parsers.ts
- Remove deleted plan/spec docs (cicd-pipeline)
- Update package.json engines and deps across workspace packages
- Update web/package-lock.json

💘 Generated with Crush

Assisted-by: GLM-5.1 via Crush <crush@charm.land>
2026-05-02 06:18:25 +02:00

49 lines
1.2 KiB
JavaScript

#!/usr/bin/env node
/**
* Dev supervisor — runs tsc --watch and watch-resources.js in parallel.
*
* Both processes terminate together when either exits or when the parent
* receives SIGINT/SIGTERM. This avoids the problem with shell backgrounding
* (`&`) where the watcher can outlive tsc and orphan.
*/
import { spawn } from 'node:child_process'
import { resolve } from 'node:path'
import { createRequire } from 'node:module'
const __dirname = import.meta.dirname
const root = resolve(__dirname, '..')
const require = createRequire(import.meta.url)
const tscBin = require.resolve('typescript/bin/tsc')
const procs = [
spawn('node', [resolve(__dirname, 'watch-resources.js')], {
cwd: root, stdio: 'inherit'
}),
spawn(process.execPath, [tscBin, '--watch'], {
cwd: root, stdio: 'inherit'
})
]
function cleanup() {
for (const p of procs) {
try { p.kill() } catch {}
}
}
// If either child exits, kill the other and exit with its code
for (const p of procs) {
p.on('exit', (code) => {
cleanup()
process.exit(code ?? 1)
})
}
// Forward signals to children
for (const sig of ['SIGINT', 'SIGTERM']) {
process.on(sig, () => {
cleanup()
process.exit(0)
})
}