Created
October 2, 2018 17:18
-
-
Save rkorsak/48c3e302cb37613cfc4b771827cdda30 to your computer and use it in GitHub Desktop.
prompt-list SIGINT example
This file contains 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
// prompt-list@3.2.0 | |
const PromptList = require('prompt-list'); | |
function wait(duration) { | |
return new Promise((resolve) => { | |
setTimeout(resolve, duration); | |
}); | |
} | |
function run() { | |
const prompt = new PromptList({ message: 'Which one?', choices: ['a', 'b', 'c'] }); | |
return prompt.run() | |
.then((choice) => { | |
console.log(`You chose ${choice}! Now wait 5 seconds...`); | |
// If you press ctrl-c during this time, nothing happens | |
return wait(5000); | |
}) | |
.then(() => { | |
console.log('Done.'); | |
}); | |
} | |
run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment