1

I have a function like this:

const runInteractive = (rows, dups) => {
  const keys = new Set(dups);

  const questions = _(rows)
    .filter(row => keys.has(row.key))
    .groupBy(row => row.key)
    .map((rows, key) => ({
      type: 'list',
      name: key.replace('.', ','),
      message: `Pick a value for ${key}`,
      choices: rows.map(row => ({ name: row.value, value: row, short: '✔' }))
    }))
    .value();

  return inquirer
    .prompt(questions)
    .then(answers => _.sortBy(rows.filter(row => !keys.has(row.key)).concat(Object.values(answers)), row => row.key));
};

I invoke it from a shebang node script.

The process is displaying the inquirer prompt and then dying.

How can I keep it alive for the user to enter input?

dagda1
  • 26,856
  • 59
  • 237
  • 450

1 Answers1

0

I know this question is old, but after a few days of struggling I figured it out and thought I would post the answer

On at least macOS/linux you can do something like this-

#!/bin/bash    

exec < /dev/tty;

node /path/to/node/file.js

where file.js is where your Inquirer prompt lives. When you call exec < /dev/tty, are you enabling the capture of user input even when your script is executed in a context without TTY.

wariofan1
  • 481
  • 2
  • 4
  • 17