(input: string)
| 88 | options: IntegerInputOptions<number | undefined> & { required: boolean }, |
| 89 | ): Promise<number | undefined> => { |
| 90 | const validate = (input: string): true | string => { |
| 91 | if (options?.helpText && input === '?') { |
| 92 | return true |
| 93 | } |
| 94 | |
| 95 | if (!options.required && input === '') { |
| 96 | return true |
| 97 | } |
| 98 | |
| 99 | if (!input.match(/^-?\d+$/)) { |
| 100 | return `"${input}" is not a valid integer` |
| 101 | } |
| 102 | |
| 103 | if (!options.validate) { |
| 104 | return true |
| 105 | } |
| 106 | |
| 107 | return options.validate(Number(input)) |
| 108 | } |
| 109 | |
| 110 | // Using `inquirer`'s `number` function instead of `input` would be nice but it doesn't allow |
| 111 | // us to accept `?` for help text. |
no outgoing calls
no test coverage detected