Skip to content

Instantly share code, notes, and snippets.

@rkorsak
Created October 2, 2018 17:18
Show Gist options
  • Save rkorsak/48c3e302cb37613cfc4b771827cdda30 to your computer and use it in GitHub Desktop.
Save rkorsak/48c3e302cb37613cfc4b771827cdda30 to your computer and use it in GitHub Desktop.
prompt-list SIGINT example
// 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