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

Support an array of formats in util.styleText #11705

Open
infrahead opened this issue Jun 8, 2024 · 3 comments
Open

Support an array of formats in util.styleText #11705

infrahead opened this issue Jun 8, 2024 · 3 comments
Labels
enhancement New feature or request node.js Compatibility with Node.js APIs node:util

Comments

@infrahead
Copy link

infrahead commented Jun 8, 2024

What is the problem this feature would solve?

Was glad to see styleText implemented in #9287 but then shortly thereafter Node added the ability to specify multiple formats in an array. Was hesitant to mark this as a bug vs feature request.

What is the feature you are proposing to solve the problem?

https://nodejs.org/api/util.html#utilstyletextformat-text
nodejs/node#52040

What alternatives have you considered?

continuing to use original API with nested function calls

@infrahead infrahead added the enhancement New feature or request label Jun 8, 2024
@paperdave paperdave added node.js Compatibility with Node.js APIs node:util labels Jun 11, 2024
Unarray added a commit to unveiled-game/unveiled that referenced this issue Jun 25, 2024
@pavi2410
Copy link

pavi2410 commented Sep 7, 2024

Just stumbled upon this issue

@aboqasem
Copy link

❯ node -e 'import util from "node:util"; console.log(util.styleText(["green", "bgBlack"], "hello"))';
hello
❯ bun -e 'import util from "node:util"; console.log(util.styleText(["green", "bgBlack"], "hello"))';
1 | import util from "node:util"; console.log(util.styleText(["green", "bgBlack"], "hello"))
                                                   ^
error: The value "green,bgBlack" is invalid for argument 'format'. Reason: must be one of: reset, bold, dim, italic, underline, blink, inverse, hidden, strikethrough, doubleunderline, black, red, green, yellow, blue, magenta, cyan, white, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, framed, overlined, gray, redBright, greenBright, yellowBright, blueBright, magentaBright, cyanBright, whiteBright, bgGray, bgRedBright, bgGreenBright, bgYellowBright, bgBlueBright, bgMagentaBright, bgCyanBright, bgWhiteBright
 code: "ERR_INVALID_ARG_VALUE"

      at styleText (node:util:131:19)
      at /Users/zouabi/dev/dotfiles/[eval]:1:48

Bun v1.1.33 (macOS x64)

@pavi2410
Copy link

I have a PR already #13807

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request node.js Compatibility with Node.js APIs node:util
Projects
None yet
Development

No branches or pull requests

4 participants