Prompt type password displaying password on windows Git Bash terminal
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
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.
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.
I just updated node to v6.7.0 and that fixed it for me at least.
If this was a node bug, you should close the issue.
@fearphage I was waiting feedback from the user reporting the bug.
@SBoudrias I was actually talking to the ticket opener :+1:
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!
I have the same problem, how is the progress about this question ? My Inquirer version is 3.3.0 (Git Bash Win7) @carreath
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.
Did you try with cmd.exe? Git bash isn't a tty terminal.
@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 yes, it's not an inquirer issue as far as I know. Git bash just appear to not support tty.
@SBoudrias cool no problem, thanks!