es-paint
A modern take on coloring CLI applications, adding colors to variables by processing template literals.
Installation
It assumes that you are running a Node.js version (4+) that has support for ES6 template literals.
npm install --save es-paint
Usage
The es-paint
returns a function that should be used as template literal
processor:
const paint = ; const version = '1.3.31';const name = 'example'; console;console;console;
Adding |>
or =>
after the template variable ${variable}
will re-color the
variables result in the given color name.
paint`|>red=>yellow`
In addition to color names, you can also use HEX colors, these are automatically transformed to the closest matching ANSI color.
console;
The example above will render hello
in normal colors and world
in
hot pink.
So, what about that use-case when people want to disable the use of colors?
const stripper = ;
Same syntax, just doesn't apply colors.
License
MIT