Skip to content

Instantly share code, notes, and snippets.

@paullessing
Created September 2, 2018 11:58
Show Gist options
  • Save paullessing/88f5374b4a98725f0f24b9eac0b4a22e to your computer and use it in GitHub Desktop.
Save paullessing/88f5374b4a98725f0f24b9eac0b4a22e to your computer and use it in GitHub Desktop.
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question(`Do a thing? (Y/n) `, answer => {
if (!answer || answer.trim().toLowerCase() === 'y') {
// do something
rl.close();
} else {
// do something else
rl.close();
process.exit(1);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment