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: enforce shouldColorize in styleText array arg #56722

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

marco-ippolito
Copy link
Member

Fixes: #56717

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module. labels Jan 23, 2025
Copy link

codecov bot commented Jan 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.21%. Comparing base (d978610) to head (d4b5727).
Report is 29 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main   #56722    +/-   ##
========================================
  Coverage   89.21%   89.21%            
========================================
  Files         662      662            
  Lines      191945   192113   +168     
  Branches    36948    36972    +24     
========================================
+ Hits       171238   171390   +152     
- Misses      13549    13550     +1     
- Partials     7158     7173    +15     
Files with missing lines Coverage Δ
lib/util.js 97.71% <100.00%> (-0.06%) ⬇️

... and 51 files with indirect coverage changes

@marco-ippolito marco-ippolito added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Jan 23, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jan 23, 2025
@nodejs-github-bot
Copy link
Collaborator

lib/util.js Outdated Show resolved Hide resolved
lib/util.js Outdated Show resolved Hide resolved
@marco-ippolito marco-ippolito force-pushed the fix-color-style-trxt branch 2 times, most recently from 4e13dd5 to 4599cad Compare January 25, 2025 11:22

return `${left}${text}${right}`;
// If the stream is falsy or should not be colorized, set skipColorize to true
skipColorize = !lazyUtilColors().shouldColorize(stream);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about returning text here if lazyUtilColors().shouldColorize(stream) is false?
(If this change is applied, we also need to modify line 122, 147, and 152)

Suggested change
skipColorize = !lazyUtilColors().shouldColorize(stream);
if (!lazyUtilColors().shouldColorize(stream)) {
return text;
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would not validate the styles which is what I wanted to avoid

@marco-ippolito marco-ippolito added the request-ci Add this label to start a Jenkins CI on a PR. label Jan 26, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jan 26, 2025
@nodejs-github-bot
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

util.styleText is not respecting NO_COLOR when first argument is an array.
5 participants