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

util.styleText is not respecting NO_COLOR when first argument is an array. #56717

Closed
fisker opened this issue Jan 23, 2025 · 0 comments · Fixed by #56722
Closed

util.styleText is not respecting NO_COLOR when first argument is an array. #56717

fisker opened this issue Jan 23, 2025 · 0 comments · Fixed by #56722

Comments

@fisker
Copy link
Contributor

fisker commented Jan 23, 2025

Version

v23.6.1

Platform

Windows 10

Subsystem

No response

What steps will reproduce the bug?

$ NO_COLOR=1 node -p "JSON.stringify(util.styleText('red', 'red'))"
"red"

$ NO_COLOR=1 node -p "JSON.stringify(util.styleText(['red'], 'red'))"
"\u001b[31mred\u001b[39m"

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

The two commands above should print the same result.

What do you see instead?

Different output.

Additional information

Looking at the implementation.

When the first argument is an array,

if (ArrayIsArray(format)) {
didn't call lazyUtilColors().shouldColorize, but it's checked when the first argument is a string
validateOneOf(key, 'format', ObjectKeys(inspect.colors));

targos pushed a commit that referenced this issue Feb 2, 2025
PR-URL: #56722
Fixes: #56717
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Deokjin Kim <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
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 a pull request may close this issue.

1 participant