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 

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

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 🎉

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.

Originally published at nikol.as on November 21, 2018.