-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
prompt blocks the terminal when use in promise chain #811
Comments
I ran into the same issue. The easier step to reproduce is basically to invoke
This will present you with two prompts, whereas the second one does not allow input (and appears to trap CTRL+C too) Tested on node v8.16.0 and v10.15.3 |
Yep the same is happening to me, only on the latest version. |
It seems working with v6.3.1, maybe windows updates cause this issue. |
Until this is fixed, one way to fix it is to make sure inquirer is bound to 6.3.x I recon for most people this comes down to changing the dependency in from
to
( |
Caused by this commit: #808 |
This should revert the upstream bug identified here: SBoudrias/Inquirer.js#811
PR here: #813 |
* feat: add inquirer bug version, reason: SBoudrias/Inquirer.js#811
No, I can't work it at 6.3.1 on MacOS |
Prompt blocks the terminal when use in promise chain SBoudrias/Inquirer.js#811
I just released Thanks all for your patience. |
in this new version 6.4.0
node v12.4.0
when i use in promise chain the second call to prompt method block the terminal
#!/usr/bin/env node
const inquirer = require("inquirer");
const prompt = inquirer.createPromptModule();
prompt(questions)
.then((answers) => {
console.log('\nOrder receipt:');
return JSON.stringify(answers);
})
.then((lastresponse) => {
return prompt(questions)
.then(function(answers) {
console.log('\nOrder receipt 2:');
console.log(lastresponse);
console.log(JSON.stringify(answers, null, ' '));
return answers;
});
})
.catch(e => {
console.error(e);
});
const questions = [{
type: 'confirm',
name: 'toBeDelivered',
message: 'Is this for delivery?',
default: false
}, {
type: 'input',
name: 'phone',
message: 'What's your phone number?',
validate: function(value) {
var pass = value.match(/^([01]{1})?[-.\s]?(?(\d{3}))?[-.\s]?(\d{3})[-.\s]?(\d{4})\s?((?:#|ext.?\s?|x.?\s?){1}(?:\d+)?)?$/i);
if (pass) {
return true;
}
return 'Please enter a valid phone number';
}
}, {
type: 'list',
name: 'size',
message: 'What size do you need?',
choices: ['Large', 'Medium', 'Small'],
filter: function(val) {
return val.toLowerCase();
}
}, {
type: 'input',
name: 'quantity',
message: 'How many do you need?',
validate: function(value) {
var valid = !isNaN(parseFloat(value));
return valid || 'Please enter a number';
},
filter: Number
}, {
type: 'expand',
name: 'toppings',
message: 'What about the toppings?',
choices: [{
key: 'p',
name: 'Pepperoni and cheese',
value: 'PepperoniCheese'
}, {
key: 'a',
name: 'All dressed',
value: 'alldressed'
}, {
key: 'w',
name: 'Hawaiian',
value: 'hawaiian'
}
]
}, {
type: 'rawlist',
name: 'beverage',
message: 'You also get a free 2L beverage',
choices: ['Pepsi', '7up', 'Coke']
}, {
type: 'input',
name: 'comments',
message: 'Any comments on your purchase experience?',
default: 'Nope, all good!'
}, {
type: 'list',
name: 'prize',
message: 'For leaving a comment, you get a freebie',
choices: ['cake', 'fries'],
when: function(answers) {
return answers.comments !== 'Nope, all good!';
}
}
];
The text was updated successfully, but these errors were encountered: