News for hackers. Stuff that matters.
Re:Dev corrupts NPM libs 'colors' and 'faker', breaking thou... by phkahler on Sunday January 09, 2022 @04:59PM (#29867740)
What exactly does colors do?
Re:Dev corrupts NPM libs 'colors' and 'faker', breaking thou... by guessmyname on Sunday January 09, 2022 @05:07PM (#29867807)
> What exactly does colors do?

A picture is worth a thousand words → https://i.imgur.com/inxA7Pg.png

The library inserts ANSI escape sequences [1] between the text you want to colorize in order to, well, colorize it ¯\_(ツ)_/¯

Many people are obsessed with colors in the Terminal, and so, they reach out to libraries like this. They exist in every major programming language ecosystem, even though colorizing text is as simple as writing this \x1b[48;5;011<TEXT>\x1[0m . One of the disadvantages of this rudimentary colorization technique is that if you have short-term memory, you will quickly forget the meaning of these numbers, but you can solve that problem with constants, there is no reason to install a third-party library with potentially malicious code to add this type of functionality to a high-profile project like AWS-CDK [2].

I wish these libraries would support NO_COLOR [3] more consistently.

I have seen many “modern” CLI tools (the ones people like to build using Rust or Go) overuse colors with no option to disable them.

[1] https://stackoverflow.com/a/33206814

[2] https://github.com/aws/aws-cdk/pull/18324/files

[3] https://no-color.org

Re:Dev corrupts NPM libs 'colors' and 'faker', breaking thou... by phkahler on Sunday January 09, 2022 @07:49PM (#29869209)
So the big question is why someone is bent out of shape for not getting MRR for writing that.
Re:Dev corrupts NPM libs 'colors' and 'faker', breaking thou... by hnthrowaway0315 on Sunday January 09, 2022 @05:50PM (#29868207)
Why wouldn't everyone roll their own solution? Doesn't seem to be a huge thing to me, but I could be wrong...
Re:Dev corrupts NPM libs 'colors' and 'faker', breaking thou... by gitgrump on Monday January 10, 2022 @01:17AM (#29871264)
Honestly? They probably don't know how, or that's just not part of the JS culture. I've met a lot of JS-only developers, and most probably don't even know what ANSI escape sequences are, let alone how to work with them. The lack of basic computer knowledge from the JS ecosystem is shocking. I don't expect this to poll well in Peoria, as it were, but this has been my consistent observation.
Re:Dev corrupts NPM libs 'colors' and 'faker', breaking thou... by guessmyname on Sunday January 09, 2022 @05:58PM (#29868274)
> Why wouldn't everyone roll their own solution? Doesn't seem to be a huge thing to me, but I could be wrong...

Laziness; and people’s infatuation for dependency trees, especially those in the Node.js & JavaScript ecosystems.

Re:Dev corrupts NPM libs 'colors' and 'faker', breaking thou... by jamil7 on Sunday January 09, 2022 @06:07PM (#29868372)
> Why wouldn't everyone roll their own solution?

JS devs will do anything to avoid this.

Re:Dev corrupts NPM libs 'colors' and 'faker', breaking thou... by cerved on Sunday January 09, 2022 @06:01PM (#29868295)
exhibit A

> even though colorizing text is as simple as writing this \x1b[48;5;011<TEXT>\x1[0m

Re:Dev corrupts NPM libs 'colors' and 'faker', breaking thou... by shepherdjerred on Sunday January 09, 2022 @05:06PM (#29867791)
https://www.npmjs.com/package/colors

> get color and style in your node.js console

Re:Dev corrupts NPM libs 'colors' and 'faker', breaking thou... by Ostrogodsky on Sunday January 09, 2022 @05:36PM (#29868037)
It's incredible how far we have come