-
-
Notifications
You must be signed in to change notification settings - Fork 35.8k
[util] Allow styleText to take in hex colors #61543
Copy link
Copy link
Closed
Labels
feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.
Description
Metadata
Metadata
Assignees
Labels
feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Projects
StatusShow more project fields
Awaiting Triage
What is the problem this feature will solve?
Many userland projects use manual hex codes for color printing to the terminal. 256 and true color printing in supported terminals is supported in several libraries that existed prior to
util.styleText. For example:ansis: supports 256 and truecolor support with fallbacks to base 16 colorschalk: has full 256 and truecolor support with fallbacks to terminal-supported levelsgradient-string: dedicated library for terminal gradients (see their 'who uses gradient string' for some pretty examples)However,
util.styleTextonly supports the standard 16 colors.What is the feature you are proposing to solve the problem?
Could
util.styleTexttake in hex codes?They could be detected as anything starting with
#.What alternatives have you considered?
Userland code could stick with raw hex code printing. But that's rather inconvenient and error-prone. Plus, functions like
styleTextrespect theNO_COLOR,NODE_DISABLE_COLORSandFORCE_COLORenvironment variables.Was this discussed in the design of
styleText? I searched around and couldn't find it.