Is your feature request related to a problem?
In my use case when pressing CTRL+C on a prompt the program should immediately terminate. Using the default confirm prompt I noted that it would answer yes and continue the program, so I implemented the following solution - is there a native one?
import prompts from 'prompts'
interface PromptState {
aborted: boolean
}
const enableTerminalCursor = () => {
process.stdout.write('\x1B[?25h')
}
const onState = (state: PromptState) => {
if (state.aborted) {
// If we don't re-enable the terminal cursor before exiting
// the program, the cursor will remain hidden
enableTerminalCursor()
process.stdout.write('\n')
process.exit(1)
}
}
export const promptConfirm = async (message: string, initial = true): Promise<boolean> => {
const { response } = await prompts([{ message, initial, onState, type: 'confirm', name: 'response' }])
return response
}
Is your feature request related to a problem?
In my use case when pressing CTRL+C on a prompt the program should immediately terminate. Using the default confirm prompt I noted that it would answer
yesand continue the program, so I implemented the following solution - is there a native one?