I am building a CLI that creates starter code for web applications. Right now we just have the UI set up with some sample questions. We want to make sure that when the user presses CRTL-C or CRTL-D the program is exited cleanly and a goodbye message appears. I was able to catch CRTL-C but it does not work for CRTL-D.
Here is the catch I have so far:
let answers = async () => {
try {
await prompt(questions)
} catch (err) {
console.log(chalk.yellow("Closing web-stater-cli..."))
}
}
answers()
But when I hit CRTL-D it just stops with no message. Does anyone have any suggestions for how to properly exit and display the message?