When inquirer prompts are used and stdin is not a tty, the prompt hangs as long as stdin is still open. We recently started using inquirer and found that one of our users has been piping in yes into one of commands to confirm all the prompts and was confused when nothing happened. I have included an extracted example to show the behavior.
'use strict';
let inquirer = require('inquirer');
inquirer.prompt([{
type: 'confirm',
name: 'yes',
message: 'Hello World?'
}]).then(function(resp) {
console.log(resp);
});
The y line is read, the problem is that the promise never fullfills so long as there is input on stdin.
-> % yes | node prompt.js
? Hello World? Yes
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
(...)
When inquirer prompts are used and stdin is not a tty, the prompt hangs as long as stdin is still open. We recently started using inquirer and found that one of our users has been piping in
yesinto one of commands to confirm all the prompts and was confused when nothing happened. I have included an extracted example to show the behavior.The
yline is read, the problem is that the promise never fullfills so long as there is input on stdin.