| 1 | import { createInterface } from 'readline'; |
| 2 | |
| 3 | export async function cliConfirm(message: string): Promise<void> { |
| 4 | const rl = createInterface({ |
| 5 | input: process.stdin, |
| 6 | output: process.stdout, |
| 7 | }); |
| 8 | |
| 9 | return new Promise(resolve => { |
| 10 | rl.question(`${message} (y/N): `, answer => { |
| 11 | rl.close(); |
| 12 | |
| 13 | const response = answer.trim().toLowerCase(); |
| 14 | |
| 15 | if (response === 'y' || response === 'yes') { |
| 16 | resolve(); |
| 17 | } else { |
| 18 | console.log("Exiting because you didn't confirm"); |
| 19 | process.exit(0); |
| 20 | } |
| 21 | }); |
| 22 | }); |
| 23 | } |