(questionText: string)
| 54 | * @returns Users's input or test input. |
| 55 | */ |
| 56 | export function interactiveQuestion(questionText: string): string { |
| 57 | // If running in a non-TTY environment and test inputs are provided |
| 58 | if (!process.stdin.isTTY && process.env.DATAFORM_CLI_TEST_INPUTS !== undefined) { |
| 59 | const testInput = getTestInput(questionText); |
| 60 | print(`${questionText} ${testInput}\n`); // Echo the test input for clarity in logs |
| 61 | return testInput; |
| 62 | } |
| 63 | |
| 64 | // If running in TTY environment or if testInputs are not available in non-TTY |
| 65 | print(`${questionText} `); |
| 66 | return readlineSync.question(""); |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Helper function to enable testing interactive CLI. Retrieves testInput from |
no test coverage detected