提交学习笔记专用
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
939 B

  1. # kolorist
  2. Tiny library to put colors into stdin/stdout :tada:
  3. ![Screenshot of terminal colors](.github/demo.png)
  4. ## Usage
  5. ```bash
  6. npm install --save-dev kolorist
  7. ```
  8. ```js
  9. import { red, cyan } from 'kolorist';
  10. console.log(red(`Error: something failed in ${cyan('my-file.js')}.`));
  11. ```
  12. You can also disable or enable colors globally via the following environment variables:
  13. - disable:
  14. - `NODE_DISABLE_COLORS`
  15. - `NO_COLOR`
  16. - `TERM=dumb`
  17. - `FORCE_COLOR=0`
  18. - enable:
  19. - `FORCE_COLOR=1`
  20. - `FORCE_COLOR=2`
  21. - `FORCE_COLOR=3`
  22. On top of that you can disable colors right from node:
  23. ```js
  24. import { options, red } from 'kolorist';
  25. options.enabled = false;
  26. console.log(red('foo'));
  27. // Logs a string without colors
  28. ```
  29. You can also strip colors from a string:
  30. ```js
  31. import { red, stripColors } from 'kolorist';
  32. console.log(stripColors(red('foo')));
  33. // Logs 'foo'
  34. ```
  35. ### License
  36. `MIT`, see [the license file](./LICENSE).