DEV Community

Nikolas Evers
Nikolas Evers

Posted on • Originally published at nikol.as on

WeeklyRandom #2: lukeed/kleur

Welcome to WeeklyRandom, a blog series in which I challenge myself to explore a random GitHub repository starred by me (almost) every week.

Let's find out which repo I can explore this time.

🥁

node index.js vintagesucks
https://github.com/lukeed/kleur

kleur by Luke Edwards. The description of the repo is as follows:

The fastest Node.js library for formatting terminal text with ANSI colors~!

Nice. Let's try to add some color to random-starred-repository, my Node.js script that powers the repository selection for WeeklyRandom. This should be done rather quickly, but could improve readability a lot.

This is how my output line looks right now:

// index.js
console.log("https://github.com/" + result[randomEntry].owner + "/" + result[randomEntry].repo)

This is how it looks:

random-starred-repository without kleur

Let's try kleur.

npm install --save kleur
// index.js
+ const { green } = require('kleur');

-  console.log("https://github.com/" + result[randomEntry].owner + "/" + result[randomEntry].repo)
+  console.log(green().bold(
+    "https://github.com/" + result[randomEntry].owner + "/" + result[randomEntry].repo
+  ))

This is how it looks now:

random-starred-repository with kleur

🎉

You can find the complete code on GitHub at vintagesucks/random-starred-repository. Pull requests with improvements are very welcome!

Until next time, when I'll check out my next WeeklyRandom repository.

Top comments (0)