Created
September 2, 2018 11:58
-
-
Save paullessing/88f5374b4a98725f0f24b9eac0b4a22e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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