Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix @inquirer/confirm formatted output value #918

Merged
merged 1 commit into from May 8, 2020
Merged

Fix @inquirer/confirm formatted output value #918

merged 1 commit into from May 8, 2020

Conversation

rbardini
Copy link
Contributor

@rbardini rbardini commented May 2, 2020

The @inquirer/confirm value is formatted twice, on keypress and once done for display:

const answer = value ? /^y(es)?/i.test(value) : config.default !== false;
setValue(answer ? 'yes' : 'no');

if (status === 'done') {
formattedValue = chalk.cyan(value ? 'yes' : 'no');

This means the final formatted value is always yes, even if the entered value is no:

Issue demo

(callback value is correct, as it is not called with the formatted value.)


This PR removes the second formatting, thus fixing the issue:

Solution demo

@SBoudrias SBoudrias merged commit a1171d2 into SBoudrias:master May 8, 2020
@SBoudrias
Copy link
Owner

Thanks!

@rbardini rbardini deleted the fix-confirm-value branch May 8, 2020 14:18
@rbardini
Copy link
Contributor Author

No problem, @SBoudrias!

Do you plan to release a new @inquirer/confirm version soon? I'd like to use it in a couple projects, but this issue is a blocker for me.

Please let me know if I can help in any way 😉

@SBoudrias
Copy link
Owner

No worries! 7.2.0 is out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants