(
message: string,
choices: { name: string; value: string | null }[],
defaultResponseIndex: number,
noTTYResponse: null | string,
)
| 30 | } |
| 31 | |
| 32 | export async function askQuestion( |
| 33 | message: string, |
| 34 | choices: { name: string; value: string | null }[], |
| 35 | defaultResponseIndex: number, |
| 36 | noTTYResponse: null | string, |
| 37 | ): Promise<string | null> { |
| 38 | if (!isTTY()) { |
| 39 | return noTTYResponse; |
| 40 | } |
| 41 | |
| 42 | const { select } = await import('@inquirer/prompts'); |
| 43 | const answer = await select({ |
| 44 | message, |
| 45 | choices, |
| 46 | default: choices[defaultResponseIndex].value, |
| 47 | theme: { |
| 48 | prefix: '', |
| 49 | }, |
| 50 | }); |
| 51 | |
| 52 | return answer; |
| 53 | } |
| 54 | |
| 55 | export async function askChoices( |
| 56 | message: string, |
no test coverage detected