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

Adopt a tool for managing colour of console text #5

Closed
shirakaba opened this issue May 18, 2024 · 4 comments
Closed

Adopt a tool for managing colour of console text #5

shirakaba opened this issue May 18, 2024 · 4 comments
Labels
good first issue Good for newcomers

Comments

@shirakaba
Copy link
Owner

So far we're using Node.js primitives, but it's kinda gross so we should migrate to something like chalk (or better).

@shirakaba shirakaba added the good first issue Good for newcomers label May 18, 2024
@lindskogen
Copy link
Collaborator

lindskogen commented May 19, 2024

Maybe we could try using console.log formatted strings?

console.log("%chello", "color: blue")

Edit: I found ANSIS which supposedly supports node/bun/deno https://github.com/webdiscus/ansis

@shirakaba
Copy link
Owner Author

shirakaba commented May 19, 2024

Hmm, I'm not clear whether console.log formatted strings are standardised. Sounds like, at least many years back, each browser handled it differently, and Node.js would be another case altogether.

So let's use a library that formalises it, yeah 👍

  • ansis: "Smaller and faster than chalk" does sound good. Recently updated, and used by thousands is good. Just surprised by its low number of GitHub stars.
  • kleur - made by Luke Edwards, is a good sign. Speed isn't a major requirement for us (this won't be used for HTTP server logging or anything, but good to see it's a priority. One downside is that the last release was two years ago, but it has no subdeps to go stale, and this is the kind of thing that could very easily reach a feature-complete state. Supports only 8 colours, but we only need as many as CocoaPods anyway. I'd expect it to support Node/Bun/Deno just due to their standard interop.
  • A bunch of other competitors compared here (on ansis's docs). The comparison is a bit out of date, as kleur now supports nested strings, too.

I think, given that as many as 12.9 million repos use kleur and yet it has only 7 open issues (none being bugs), it seems to be a solid choice. The package (2.7KB) is a little smaller than ansis (3.5KB), too. I think let's go with kleur!

@shirakaba
Copy link
Owner Author

I've integrated kleur now! 🥳

@webdiscus
Copy link

@shirakaba,

ansis has few stars on GitHub because this package has very few visitors on GitHub.
Perhaps most developers uses already "old school" packages, like chalk since 10-5-3 years and do not need new ones.

P.S. You can see the features comparison and benchmarks of most popular terminal colors libraries:
ansis, chalk, kleur, kolorist, colors.js, colorette, picocolors, ansi-colors, cli-color, colors-cli

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

No branches or pull requests

3 participants