From 35bebfa849b12cffd003147f5b37f3539788ff27 Mon Sep 17 00:00:00 2001 From: Pavel Lang Date: Thu, 27 Dec 2018 20:39:59 +0100 Subject: [PATCH] docs(stderr): chalk vs chalk/stderr --- readme.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/readme.md b/readme.md index d8ca070..78f0e86 100644 --- a/readme.md +++ b/readme.md @@ -55,9 +55,13 @@ $ npm install chalk ## Usage ```js +// for stdout: console.log, console.info, console.debug const chalk = require('chalk'); +// for stderr: console.error, console.warn +const cherr = require('chalk/stderr'); console.log(chalk.blue('Hello world!')); +console.error(cherr.red('Oh, colored error!')); ``` Chalk comes with an easy to use composable API where you just chain and nest the styles you want. @@ -173,6 +177,16 @@ Can be overridden by the user with the flags `--color` and `--no-color`. For sit Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively. +### `chalk` vs `chalk/stderr` + +For simplicity of use, there is `chalk/stderr` export. +Everything exported from `chalk` is also exported from `chalk/stderr`. +Only differense is actual value of `supportsColor` exported: + +- for `chalk` import, `supportsColor` depends on `stdout` +- for `chalk/stderr` value depends on `stderr` + +This may differ if one of the standart outputs is redirected and the other is not. ## Styles