| 1 | // Fixture used by DevCommand.test.ts. Writes its PID + a marker (so the test |
| 2 | // can tell two consecutive spawns apart) and then sleeps forever. The test |
| 3 | // uses `process.kill(pid, 0)` to assert liveness from the outside. |
| 4 | const fs = require("node:fs"); |
| 5 | |
| 6 | const file = process.env.PID_FILE; |
| 7 | const marker = process.env.MARKER ?? "default"; |
| 8 | |
| 9 | if (!file) { |
| 10 | console.error("long-running.cjs: PID_FILE env var is required"); |
| 11 | process.exit(1); |
| 12 | } |
| 13 | |
| 14 | fs.writeFileSync(file, JSON.stringify({ pid: process.pid, marker })); |
| 15 | |
| 16 | // Print a localhost URL so the Dev provider's URL-readiness scan resolves |
| 17 | // immediately (like a real dev server) instead of waiting out its 5-second |
| 18 | // budget. Tests that use this fixture assert on process lifecycle, not URL |
| 19 | // extraction — url-server.cjs covers that. |
| 20 | console.log("http://localhost:65535/"); |
| 21 | |
| 22 | // Hold the event loop open without doing any actual work. |
| 23 | setInterval(() => {}, 60_000); |