From 54cc022ff3f918f784bbaebee556549c2884edbc Mon Sep 17 00:00:00 2001 From: Adam <34751694+avb100@users.noreply.github.com> Date: Mon, 14 May 2018 01:37:36 -0400 Subject: [PATCH] Hide default values for passwords (#668) Addressing issue #635, this PR displays `[hidden]` as the default value instead of displaying the actual password, when applicable. The message is consistent with text displayed when the password is masked. --- lib/prompts/base.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/prompts/base.js b/lib/prompts/base.js index 5ef9c38a1..25366c454 100644 --- a/lib/prompts/base.js +++ b/lib/prompts/base.js @@ -128,7 +128,12 @@ class Prompt { // Append the default if available, and if question isn't answered if (this.opt.default != null && this.status !== 'answered') { - message += chalk.dim('(' + this.opt.default + ') '); + // If default password is supplied, hide it + if (this.opt.type === 'password') { + message += chalk.italic.dim('[hidden] '); + } else { + message += chalk.dim('(' + this.opt.default + ') '); + } } return message;