Skip to content

Instantly share code, notes, and snippets.

@chug2k
Created April 12, 2020 15:05
Show Gist options
  • Save chug2k/729fb3d5e68011c60593298e7c9c0e7b to your computer and use it in GitHub Desktop.
Save chug2k/729fb3d5e68011c60593298e7c9c0e7b to your computer and use it in GitHub Desktop.
Khoa's awesome chalk addon
- OPTIONAL: Well, it's pretty cool and handy ...not. At the time I used this lib for the first time, I felt like I had to type too many characters just to log a string 😄 , so I created a couple of methods that will make it a lot shorter. E.g:
```js
console.log(chalk.red.bold("Hello world!"));
c.red("Hello world!"); // same output as above
```
- OPTIONAL: Here is the code if you want to use it, you can also customize it to suit your needs. Create a file `modules/chalk.js` with the content of following code:
```js
const c = require("chalk");
class Print {
blue(...t) {
console.log(c.blue.bold(...t));
}
yellow(...t) {
console.log(c.yellow.bold(...t));
}
green(...t) {
console.log(c.green.bold(...t));
}
black(...t) {
console.log(c.black.bold(...t));
}
red(...t) {
console.log(c.red.bold(...t));
}
}
module.exports = new Print();
```
- And use it like this:
```js
const c = require("./modules/chalk");
c.blue("Leeeroy jenkins");
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment