(prompt: string)
| 108 | } |
| 109 | |
| 110 | function askQuestion(prompt: string): Promise<string> { |
| 111 | return new Promise((resolve) => { |
| 112 | const rl = readline.createInterface({ |
| 113 | input: process.stdin, |
| 114 | output: process.stdout, |
| 115 | }); |
| 116 | rl.question(prompt, (answer) => { |
| 117 | rl.close(); |
| 118 | resolve(answer); |
| 119 | }); |
| 120 | // Auto-resolve after 10 seconds so the CLI never hangs |
| 121 | const timeout = setTimeout(() => { |
| 122 | rl.close(); |
| 123 | resolve(""); |
| 124 | }, 10_000); |
| 125 | // Don't keep the process alive just for the timeout |
| 126 | if (typeof timeout === "object" && timeout !== null && "unref" in timeout) { |
| 127 | (timeout as { unref: () => void }).unref(); |
| 128 | } |
| 129 | }); |
| 130 | } |
no test coverage detected