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

Not registering the second option in prompt.get([optiion1,option2])....etc #131

Closed
jdalrymple opened this issue Oct 16, 2015 · 21 comments
Closed

Comments

@jdalrymple
Copy link

Allows me to enter in the first option value, but once i click enter to move to the following option2, it just returns, showing the second option as a blank value. I added three options and it still skipped the second one and worked find for the third which is also odd.

I used this code to test:

var prompt = require('prompt');

  //
  // Start the prompt
  //
  prompt.start();

  //
  // Get two properties from the user: username and email
  //
  prompt.get(['username', 'email'], function (err, result) {
    //
    // Log the results.
    //
    console.log('Command-line input received:');
    console.log('  username: ' + result.username);
    console.log('  email: ' + result.email);
  });
@mikeRead
Copy link

Im having the same problem,Admins should probably merge my issue #132 into this as it looks to be the same thing... sorry I tried searching but didn't see this until I was looking at my issue again today.

I "fixed" it by doing something like this by adding the second parameter as "bug"
(didn't test this example)

 prompt.get(['username', 'bug', 'email'], function (err, result) {
    //
    // Log the results.
    //
    console.log('Command-line input received:');
    console.log('  username: ' + result.username);
    console.log(' ignore: ' + result.bug);
    console.log('  email: ' + result.email);
  });

@jdalrymple
Copy link
Author

Noticed on one of my other computers using an older version of node, the problem doesn't exist. Im going to upgrade and see if it returns. Also error happened on my windows machine. My linux machine with the older node,js works fine (node -v = 0.12.7-1)

@jdalrymple
Copy link
Author

Tested with linux node version 4.2.1 Also works fine. @mikeRead are you running it on windows?

@mikeRead
Copy link

Thanks, I am running on windows using node v4.1.1

@jdalrymple
Copy link
Author

I test on windows with node v4.2.1 and the bug happened.

@jonathansampson
Copy link

I also appear to be hitting this bug on Windows 10, running Node 4.2.1. Issue existed in both Command Prompt, as well as in PowerShell.

@cameronk
Copy link

cameronk commented Nov 2, 2015

This bug has something to do with the way the prompt is initialized - it only occurs after the first input.

var promptSchema = {
    properties: {
        "Mission name": {
            pattern: /^[a-zA-Z\s\-]+$/,
            message: 'Name must be only letters, spaces, or dashes',
            required: true
        },
        "Skip this prompt": {

        },
        "Admin username": {
            required: true
        }, 
        "Admin PIN": {
            required: true
        }
    }
};

Running prompt with this schema and entering invalid input into the first prompt ("Mission name") causes the error message to pop up, then immediately pop up again (because the program outputs the error but also receives it as input, which is invalid based on that pattern). Entering correct input afterwards and you get through all four prompts.

@mikeRead
Copy link

mikeRead commented Nov 2, 2015

Its a bit off topic but you probably need to use description if your keys have space in them

...
//remove space
"Mission_name": {
            //add description
            description:"Mission name",
            pattern: /^[a-zA-Z\s\-]+$/,
            message: 'Name must be only letters, spaces, or dashes',
            required: true
        }, 
...

@cameronk
Copy link

cameronk commented Nov 2, 2015

Hmm. I ran node using the "Git Bash" program that comes shipped with Github's Windows desktop program and the bug seems to be gone.

@mikeRead
Copy link

mikeRead commented Nov 2, 2015

I'm not sure exactly what you mean but running npm install https://github.com/flatiron/prompt.git --save didn't work for me in my project it should be the exact same code? what version of node are you using?

@cameronk
Copy link

cameronk commented Nov 3, 2015

I'm talking about the command prompt window. If you install Github for Windows, you also receive "Git Bash" which a port of the Linux-style environment/command-line tools.

Node version 4.2.1

@nickdbush
Copy link

On all of my command prompts this error happens. Especially annoying when trying to type in passwords! Command Prompt, PowerShell, Git and CMDer all display this bug. Any ETA on this being fixed?

Running Windows 10 64bit with Node 5.0.0

@cdoole
Copy link

cdoole commented Dec 1, 2015

I'm also using windows 10 64bit but i have Node 4.2.2. I'm working on a project for a course and it keeps skipping the second parameter

@masiorama
Copy link

Windows 10 64bit but i have Node 4.2.2, same problem here.

@gregwilton
Copy link

Upgrading to Node 5.3.0 fixed this for me. Was previously getting this error on Node 4.0.0 on Win 10.

@Cellule
Copy link

Cellule commented Jan 29, 2016

I had the same issue, I upgraded from Node 4.1.2 => 5.5.0 and the bug is gone.

@jcrugzz
Copy link
Member

jcrugzz commented Jan 29, 2016

still an issue with node@4.2.6?

@gangstead
Copy link
Member

Not sure if/how to resolve this one. It sounds like some magic in Node 5 fixes it, but I don't have a Windows machine to verify that it works or not on any version of Node. Anybody still having the problem on Node 5?

@gangstead
Copy link
Member

I'm going to go ahead and close since we have a fix (Windows users upgrade to Node 5). It doesn't give me warm feelings that the root cause wasn't found, but at least we have an answer for anyone else with the problem. We can always reopen to keep the discussion going if anyone disagrees.

@edupoly
Copy link

edupoly commented Mar 8, 2022

'prompt' package is useless in windows. Use 'inquirer' for better results

@caub
Copy link
Contributor

caub commented Mar 8, 2022

@edupoly or https://www.npmjs.com/package/prompt-ajv for a light and simple alternative

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests