Skip to content

Commit

Permalink
Bugfix (password): Don't format helpTip as the answer
Browse files Browse the repository at this point in the history
  • Loading branch information
SBoudrias committed Jan 27, 2024
1 parent b5cc2f5 commit 1d61ed8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/password/src/index.mts
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ export default createPrompt<string, PasswordConfig>((config, done) => {
});

const message = chalk.bold(config.message);
let formattedValue = '';

let formattedValue = '';
let helpTip;
if (config.mask) {
const maskChar = typeof config.mask === 'string' ? config.mask : '*';
formattedValue = maskChar.repeat(value.length);
} else if (status !== 'done') {
formattedValue = `${chalk.dim('[input is masked]')}${ansiEscapes.cursorHide}`;
helpTip = `${chalk.dim('[input is masked]')}${ansiEscapes.cursorHide}`;
}

if (status === 'done') {
Expand All @@ -69,5 +70,5 @@ export default createPrompt<string, PasswordConfig>((config, done) => {
error = chalk.red(`> ${errorMsg}`);
}

return [`${prefix} ${message} ${formattedValue}`, error];
return [[prefix, message, formattedValue, helpTip].filter(Boolean).join(' '), error];
});

0 comments on commit 1d61ed8

Please sign in to comment.