Skip to content

Commit

Permalink
Bugfix (input): Do not reformat final transform
Browse files Browse the repository at this point in the history
  • Loading branch information
SBoudrias committed Jan 27, 2024
1 parent c52a91f commit b5cc2f5
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions packages/input/src/index.mts
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,19 @@ export default createPrompt<string, InputConfig>((config, done) => {
let formattedValue = value;
if (typeof config.transformer === 'function') {
formattedValue = config.transformer(value, { isFinal: status === 'done' });
}
if (status === 'done') {
formattedValue = chalk.cyan(formattedValue);
} else if (status === 'done') {
formattedValue = chalk.cyan(value);
}

let defaultStr = '';
let defaultStr;
if (defaultValue && status !== 'done' && !value) {
defaultStr = chalk.dim(` (${defaultValue})`);
defaultStr = chalk.dim(`(${defaultValue})`);
}

let error = '';
if (errorMsg) {
error = chalk.red(`> ${errorMsg}`);
}

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

0 comments on commit b5cc2f5

Please sign in to comment.