()
| 19 | } |
| 20 | |
| 21 | async function run() { |
| 22 | runBuild() |
| 23 | |
| 24 | const server = spawn(tsxCommand, ['./server/index.mjs'], { |
| 25 | cwd, |
| 26 | stdio: 'inherit', |
| 27 | }) |
| 28 | |
| 29 | const stopServer = (signal) => { |
| 30 | if (server.exitCode === null) { |
| 31 | server.kill(signal) |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | process.on('SIGINT', () => stopServer('SIGINT')) |
| 36 | process.on('SIGTERM', () => stopServer('SIGTERM')) |
| 37 | |
| 38 | const outcome = await Promise.race([ |
| 39 | once(server, 'error').then(([error]) => { |
| 40 | throw error |
| 41 | }), |
| 42 | once(server, 'exit').then(([code]) => ({ code })), |
| 43 | ]) |
| 44 | |
| 45 | process.exitCode = outcome.code ?? 0 |
| 46 | } |
| 47 | |
| 48 | run().catch((error) => { |
| 49 | console.error(error) |
no test coverage detected