Skip to content

Commit

Permalink
Keep password prompt silenced after error - Fix #553 #546
Browse files Browse the repository at this point in the history
  • Loading branch information
SBoudrias committed Jun 18, 2017
1 parent 11f5854 commit 948f8dc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
19 changes: 13 additions & 6 deletions examples/password.js
Expand Up @@ -3,20 +3,27 @@
*/

'use strict';
var inquirer = require('..');
const inquirer = require('..');

const requireLetterAndNumber = value => {
if (/\w/.test(value) && /\d/.test(value)) {
return true;
}
return 'Password need to have at least a letter and a number';
};

inquirer.prompt([
{
type: 'password',
message: 'Enter a password',
name: 'password1'
name: 'password1',
validate: requireLetterAndNumber
},
{
type: 'password',
message: 'Enter a masked password',
name: 'password2',
mask: '*'
mask: '*',
validate: requireLetterAndNumber
}
]).then(function (answers) {
console.log(JSON.stringify(answers, null, ' '));
});
]).then(answers => console.log(JSON.stringify(answers, null, ' ')));
5 changes: 0 additions & 5 deletions lib/prompts/password.js
Expand Up @@ -108,13 +108,8 @@ Prompt.prototype.onEnd = function (state) {

Prompt.prototype.onError = function (state) {
this.render(state.isValid);
this.rl.output.unmute();
};

/**
* When user type
*/

Prompt.prototype.onKeypress = function () {
this.render();
};

0 comments on commit 948f8dc

Please sign in to comment.