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

type: 'password' being shown while the second one was hidden

Open Mrooze-zeng opened this issue 8 years ago • 5 comments

git bash

$ node -v
v8.9.1
$ npm -v
5.5.1
		inquirer
  			.prompt([
		    	{
			      type: 'password',
			      mask: '*',			
			      message: 'Enter a password',
			      name: 'password'
			    }
			  ])
		    .then(answers => console.log(JSON.stringify(answers)));

Output is the following

$ hei readDir
? Enter a password aaa
? Enter a password ***
{"password":"aaa"}

when i enter my password ,the password was showed on then terminal,and i pressed enter key ,it showed a new line with my password hidden

Mrooze-zeng avatar Dec 05 '17 10:12 Mrooze-zeng

Unable to reproduce in the latest version using examples/password.js

kbrandwijk avatar Jan 10 '18 06:01 kbrandwijk

Same happens to me. I debug a lot. Seems when ever you run js as bash. It not working as it suppose to work on git-bash. can be reproduce

#!/usr/bin/env node

// rest of the code.
examples/password.js

deepakshrma avatar Jan 12 '18 08:01 deepakshrma

I can reproduce this issue using nodemon 1.14.3:

gms@sirius:~/work/HOT/sandbox (master)$ ./node_modules/.bin/nodemon ./index.js 
[nodemon] 1.14.3
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node ./index.js`
? test password:  1234
? test password:  ****
testinput:  {
  "password": "1234"
}

but not, if I run the same code from node 8.9.4 directly:

gms@sirius:~/work/HOT/sandbox (master)$ node --version
v8.9.4
gms@sirius:~/work/HOT/sandbox (master)$ node ./index.js 
? test password:  ****
testinput:  {
  "password": "1234"
}

the code for the tests above:

const inquirer = require('inquirer');
inquirer.prompt([{name: 'password', type: 'password', message: 'test password: ', mask: '*'}]).then((answers) => {
  console.log(`testinput: `, JSON.stringify(answers, undefined, 2));
  return answers.password;
});

my shell is bash 4.4.12:

gms@sirius:~/work/HOT/sandbox (master)$ bash -version                          
GNU bash, Version 4.4.12(1)-release (x86_64-pc-linux-gnu)
...

gms1 avatar Jan 20 '18 17:01 gms1

Oh, I'm so sorry! nodemon --no-stdin did the trick

gms1 avatar Jan 20 '18 18:01 gms1

@gms1 yeah, highly probable Nodemon doesn't pipe a fully interactive prompt by default to the subprocess it spawns.

Any chance other people reporting this issue are also not running Inquirer through raw node process?

SBoudrias avatar Jan 21 '18 05:01 SBoudrias