Skip to content

opts.stdout not working #208

@saurabhdaware

Description

@saurabhdaware

Describe the bug

As mentioned in the code, the prompt is supposed to take parameter args.stdout. I tried passing process.stderr to stdout but it doesn't seem to work.

To Reproduce

Steps to reproduce the behavior:

  1. . Create index.js with basic autocomplete prompt code and set question.stdout = process.stderr (this is supposed to make terminal wait so command substitution like eval $(command) can work)
  2. print any random path for testing when a specific value is selected.
  3. cd $(node index.js) This will not show the autocomplete

Expected behavior

In the above scenario, it should first show the autocomplete prompt and on selecting that particular option it should cd to the mentioned path

System

  • OS: [e.g. MacOS 10.14.3] Ubuntu 19
  • Terminal: [e.g. iTerm, PowerShell] Ubuntu Terminal
  • Node version: node -v 10.16.0

Additional context

Add any other context about the problem here.
I looked around the code and found following code in lib/elements/prompt.js

 class Prompt extends EventEmitter {
       this.firstRender = true;
       this.in = opts.in \|\| process.stdin;
       this.out = opts.out \|\| process.stdout;

Isn't opts.out is supposed to be opts.stdout in above code? since args.stdout is mentioned everywhere while mentioning the arguments.

EDIT: I tried having out instead of stdout and it does wait for the input but it re-renders autocomplete list everytime you press key.

 const questions = [
            {
                type: 'autocomplete',
                message: `Select project to ${action} :`,
                name: 'selectedProject',
                choices:getChoices(),
                limit:40,
                suggest:suggestFilter,
                out:process.stderr
            }
        ];

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions