| 33 | } |
| 34 | |
| 35 | function parse(argv: string[]): Options | undefined { |
| 36 | let live = false; |
| 37 | let gh = ""; |
| 38 | let output = ""; |
| 39 | for (let index = 0; index < argv.length; index++) { |
| 40 | const arg = argv[index]!; |
| 41 | if (arg === "--help" || arg === "-h") { console.log(usage); return; } |
| 42 | if (arg === "--live") live = true; |
| 43 | else if (arg === "--gh") gh = argv[++index] ?? ""; |
| 44 | else if (arg === "--output") output = argv[++index] ?? ""; |
| 45 | else throw new Error(`Unknown option: ${arg}\n${usage}`); |
| 46 | } |
| 47 | if (!live) throw new Error(`Live operations require --live.\n${usage}`); |
| 48 | if (!gh) throw new Error(`--gh requires an already-built binary.\n${usage}`); |
| 49 | return { |
| 50 | gh, |
| 51 | output: output || join(process.env.XDG_STATE_HOME || join(homedir(), ".local/state"), |
| 52 | "gh-event-evals/smoke", new Date().toISOString().replaceAll(":", "-")), |
| 53 | }; |
| 54 | } |
| 55 | |
| 56 | function waitForExit(child: ChildProcess): Promise<{ code: number | null; signal: NodeJS.Signals | null }> { |
| 57 | return new Promise((resolveExit, reject) => { |