SBoudrias / Inquirer.js

A collection of common interactive command line user interfaces.
MIT License
19.72k stars 1.28k forks source link

Editor type does not wait for file to close when using editors other than vim #1155

Open DanielOrtel opened 1 year ago

DanielOrtel commented 1 year ago

When using, for example, subl as the default editor of the system, the command does not wait for the file to close, instead it just ends, therefore no answers are passed to the command.

Repro:

import inquirer from 'inquirer';

inquirer
  .prompt([
    {
      type: 'editor',
      name: 'theme',
      message: 'What do you want to do?',
      waitUserInput: true, // <-- does not do anything here
      postfix: 'json' // <-- fyi, this one doesn't work either, but there's already an open issue
    },
  ])
  .then((answers) => {
    console.log(JSON.stringify(answers, null, '  '));
  });

node: v12.22.1 OS: macOS Monterey 12.4

SBoudrias commented 1 year ago

This might be an issue with the underlying modules handling external editors: https://github.com/mrkmg/node-external-editor

gfargo commented 1 year ago

I'm experiencing an issue, similar to others (#985), where the prompt doesn't wait for the external editor to close the file.

This doesn't impact editors running within the terminal e.g. nano, or vi, vim, only external editors like subl or code.

mensah-j commented 2 months ago

I'm experiencing an issue, similar to others (#985), where the prompt doesn't wait for the external editor to close the file.

This doesn't impact editors running within the terminal e.g. nano, or vi, vim, only external editors like subl or code.

See #985. For Sublime Text, you can also use subl -w or subl --wait.