Inquirer.js icon indicating copy to clipboard operation
Inquirer.js copied to clipboard

Prompt type password displaying password on windows Git Bash terminal

Open carreath opened this issue 10 years ago • 13 comments

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

carreath avatar Sep 30 '16 14:09 carreath

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.

razzlero avatar Oct 01 '16 20:10 razzlero

Some node version ship with a totally broken readline.

See https://github.com/nodejs/node/issues/5384 for more details. You'll want to try again on latest stable Node.js version.

SBoudrias avatar Oct 01 '16 20:10 SBoudrias

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

razzlero avatar Oct 01 '16 22:10 razzlero

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

fearphage avatar Oct 04 '16 04:10 fearphage

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

SBoudrias avatar Oct 04 '16 04:10 SBoudrias

@SBoudrias I was actually talking to the ticket opener :+1:

fearphage avatar Oct 04 '16 05:10 fearphage

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 avatar Oct 04 '16 10:10 carreath

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

lmh2072005 avatar Oct 25 '17 08:10 lmh2072005

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.

carreath avatar Oct 25 '17 08:10 carreath

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

SBoudrias avatar Oct 26 '17 02:10 SBoudrias

@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.

cckelly avatar Jul 12 '18 19:07 cckelly

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

SBoudrias avatar Jul 15 '18 02:07 SBoudrias

@SBoudrias cool no problem, thanks!

cckelly avatar Jul 16 '18 14:07 cckelly