kolorist

A tiny utility to colorize stdin/stdout

README

kolorist


Tiny library to put colors into stdin/stdout :tada:

Screenshot of terminal colors

Usage


  1. ```bash
  2. npm install --save-dev kolorist
  3. ```

  1. ```js
  2. import { red, cyan } from 'kolorist';

  3. console.log(red(`Error: something failed in ${cyan('my-file.js')}.`));
  4. ```

You can also disable or enable colors globally via the following environment variables:

- disable:
  - NODE_DISABLE_COLORS
  - NO_COLOR
  - TERM=dumb
  - FORCE_COLOR=0

- enable:
  - FORCE_COLOR=1
  - FORCE_COLOR=2
  - FORCE_COLOR=3

On top of that you can disable colors right from node:

  1. ```js
  2. import { options, red } from 'kolorist';

  3. options.enabled = false;
  4. console.log(red('foo'));
  5. // Logs a string without colors
  6. ```

You can also strip colors from a string:

  1. ```js
  2. import { red, stripColors } from 'kolorist';

  3. console.log(stripColors(red('foo')));
  4. // Logs 'foo'
  5. ```

License