Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opts.stdout not working #208

Closed
saurabhdaware opened this issue Sep 18, 2019 · 3 comments
Closed

opts.stdout not working #208

saurabhdaware opened this issue Sep 18, 2019 · 3 comments
Labels
bug Something isn't working

Comments

@saurabhdaware
Copy link
Contributor

saurabhdaware commented Sep 18, 2019

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
            }
        ];
@terkelg
Copy link
Owner

terkelg commented Oct 18, 2019

Thank you for the PR!

@jamezrin
Copy link
Contributor

This issue can be closed, it's fixed

@terkelg
Copy link
Owner

terkelg commented Feb 14, 2020

Thank you @jamezrin!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants