(
message: string,
options: OptionalStringInputOptions & { required: boolean },
)
| 24 | helpText?: string |
| 25 | } |
| 26 | const internalStringInput = async ( |
| 27 | message: string, |
| 28 | options: OptionalStringInputOptions & { required: boolean }, |
| 29 | ): Promise<string> => { |
| 30 | const optValidate = options.validate |
| 31 | const validate = (options?.helpText && optValidate) |
| 32 | ? (input: string) => input === '?' || optValidate(input) |
| 33 | : optValidate |
| 34 | const question = { |
| 35 | message: options?.helpText ? `${message} (? for help)` : message, |
| 36 | default: typeof options?.default === 'function' ? options.default() : options?.default, |
| 37 | validate, |
| 38 | required: options.required, |
| 39 | } |
| 40 | |
| 41 | let entered = await input(question) |
| 42 | while (options?.helpText && entered === '?') { |
| 43 | console.log(options.helpText) |
| 44 | entered = await input(question) |
| 45 | } |
| 46 | |
| 47 | return entered |
| 48 | } |
| 49 | |
| 50 | export const optionalStringInput = async ( |
| 51 | message: string, |
no outgoing calls
no test coverage detected