Inquirer.js icon indicating copy to clipboard operation
Inquirer.js copied to clipboard

Prompt confirm does not work with yes unix command

Open ransombriggs opened this issue 8 years ago • 8 comments

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
(...)

ransombriggs avatar Apr 22 '16 16:04 ransombriggs