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

Prompt type password displaying password on windows Git Bash terminal #421

Closed
carreath opened this issue Sep 30, 2016 · 13 comments
Closed

Comments

@carreath
Copy link

carreath commented Sep 30, 2016

I am not entirely sure if this is a bug or not but on my windows Git Bash terminal the password prompt type is not hiding input.

 var prompt = function(main, length, defaults, cb) {
    var prompt = {
        type: 'password',
        name: 'password',
        message: chalk.red('(3/3) Please enter your password '),
        validate: function (value) {
              var pass = (value.length > 6);
              if (pass) {
                    return true;
              }
              return 'Please enter a valid username';
        }
    }

    main.prompt(prompt, function (props) {
        var keys = Object.keys(props);
        for(var i=0; i<keys.length; i++) {
            returnValues.push(props[keys[i]]);            
        }
        cb();
    }.bind(main));
 }

on screen (Git Bash Win10):

[?]Please enter your password: blahpassword
[?]Please enter your password: ************

on screen (Terminal Ubuntu):

[?]Please enter your password: ************

*Note I am running inquirer 1.1.3 with yeoman env 1.6.4 and npm 3.10.3

@razzlero
Copy link

razzlero commented Oct 1, 2016

I just did some testing and I can replicate it on my system. So I'll share what I found. It's happening for me in git bash, windows cmd, and cygwin all on windows 10. I haven't tried it on any other OS yet.

The problem seems to be with the calling of the onKeypress function in password.js. I put a console.log statement into it to test when it's being called, it seems to trigger only after you press enter. It then triggers once for every character in the string.

Here's en example of what happens when I put a "Debug statement inside" the onKeypress Fucntion

$ node password.js
? Enter your git password test
Debug statement
? Enter your git password *Debug statement
? Enter your git password **Debug statement
? Enter your git password ***Debug statement
? Enter your git password ****
{
  "password": "test"
}

onKeyPress is beign called on line 52 of password.js by
events.keypress.takeUntil(validation.success).forEach(this.onKeypress.bind(this));
So something funny is happening with that.

@SBoudrias
Copy link
Owner

Some node version ship with a totally broken readline.

See nodejs/node#5384 for more details. You'll want to try again on latest stable Node.js version.

@razzlero
Copy link

razzlero commented Oct 1, 2016

I just updated node to v6.7.0 and that fixed it for me at least.

@fearphage
Copy link

If this was a node bug, you should close the issue.

@SBoudrias
Copy link
Owner

@fearphage I was waiting feedback from the user reporting the bug.

@fearphage
Copy link

@SBoudrias I was actually talking to the ticket opener 👍

@carreath
Copy link
Author

carreath commented Oct 4, 2016

Oh sorry, I have been able to fix the problem on the password.js file itself but yeoman didn't change. I have the same node version that was described as working earlier. However I have the same error.

I am pretty sure it is a problem with the yeoman generator and it is going to take me a while to figure out how it works on Windows. And if worst comes to worst I can just replicate the prompt in the bash file I call directly after prompting for password.

If I am able to fix the bug in the future and it is inquirer I will come back and update.

Thanks for the help though!

@carreath carreath closed this as completed Oct 4, 2016
@lmh2072005
Copy link

lmh2072005 commented Oct 25, 2017

I have the same problem, how is the progress about this question ? My Inquirer version is 3.3.0 (Git Bash Win7) @carreath

@carreath
Copy link
Author

I wasn’t able to fix this issue as I believed it was just caused by an incorrect installation of inquirer. I also thought it may have been git bash giving issues on text replace with the password mask.

@SBoudrias
Copy link
Owner

Did you try with cmd.exe? Git bash isn't a tty terminal.

@cckelly
Copy link

cckelly commented Jul 12, 2018

@SBoudrias sorry for rehashing an old issue but is it determined that this is a Git Bash issue and not an inquirer issue? I'm on inquirer 6.0.0. Confirmed that cmd.exe works.

@SBoudrias
Copy link
Owner

@cckelly yes, it's not an inquirer issue as far as I know. Git bash just appear to not support tty.

@cckelly
Copy link

cckelly commented Jul 16, 2018

@SBoudrias cool no problem, thanks!

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

6 participants