Skip to content

Prompt confirm does not work with yes unix command #365

@ransombriggs

Description

@ransombriggs

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions