(...args: string[])
| 6 | // Given input variables to a command, make sure all are provided if the terminal |
| 7 | // is not interactive (because we won't be able to prompt the user) |
| 8 | export const checkInteractive = (...args: string[]): boolean => { |
| 9 | if (isInteractive()) { |
| 10 | return true; |
| 11 | } |
| 12 | |
| 13 | // Fail if no args are provided, treat this as just a check of whether the term is |
| 14 | // interactive or not. |
| 15 | if (!args.length) { |
| 16 | return false; |
| 17 | } |
| 18 | |
| 19 | // Make sure none of the provided args are empty, otherwise print the interactive |
| 20 | // warning and return false |
| 21 | if (args.filter((arg) => !arg).length) { |
| 22 | logger.error( |
| 23 | `Non-interactive shell detected.\n` + |
| 24 | `Run the command with ${c.input('--help')} to see a list of arguments that must be provided.`, |
| 25 | ); |
| 26 | return false; |
| 27 | } |
| 28 | return true; |
| 29 | }; |
| 30 | |
| 31 | export const isInteractive = (): boolean => TERMINAL_INFO.tty && !TERMINAL_INFO.ci; |
no test coverage detected