Comparing version
const { FORCE_COLOR, NODE_DISABLE_COLORS, TERM } = process.env; | ||
const $ = exports.$ = { | ||
enabled: !NODE_DISABLE_COLORS && TERM !== 'dumb' && FORCE_COLOR !== '0' | ||
enabled: !NODE_DISABLE_COLORS && TERM !== 'dumb' && ( | ||
FORCE_COLOR != null && FORCE_COLOR !== '0' || process.stdout.isTTY | ||
) | ||
} | ||
@@ -6,0 +8,0 @@ |
@@ -6,3 +6,5 @@ 'use strict'; | ||
const $ = { | ||
enabled: !NODE_DISABLE_COLORS && TERM !== 'dumb' && FORCE_COLOR !== '0', | ||
enabled: !NODE_DISABLE_COLORS && TERM !== 'dumb' && ( | ||
FORCE_COLOR != null && FORCE_COLOR !== '0' || process.stdout.isTTY | ||
), | ||
@@ -9,0 +11,0 @@ // modifiers |
{ | ||
"name": "kleur", | ||
"version": "4.0.1", | ||
"version": "4.0.2", | ||
"repository": "lukeed/kleur", | ||
@@ -32,3 +32,3 @@ "description": "The fastest Node.js library for formatting terminal text with ANSI colors~!", | ||
"build": "node build", | ||
"test": "uvu -r esm -i utils" | ||
"test": "uvu -r esm -i utils -i xyz" | ||
}, | ||
@@ -48,4 +48,4 @@ "engines": { | ||
"esm": "3.2.25", | ||
"uvu": "0.0.11" | ||
"uvu": "0.0.16" | ||
} | ||
} |
@@ -90,2 +90,4 @@ <div align="center"> | ||
> **Note:** Both `kleur` and `kleur/colors` share the same detection logic. | ||
```js | ||
@@ -103,3 +105,11 @@ import kleur from 'kleur'; | ||
> **Important:** <br>Colors will be disabled automatically in non [TTY contexts](https://nodejs.org/api/process.html#process_a_note_on_process_i_o). For example, spawning another process or piping output into another process will disable colorization automatically. To force colors in your piped output, you may do so with the `FORCE_COLOR=1` environment variable: | ||
```sh | ||
$ node app.js #=> COLORS | ||
$ node app.js > log.txt #=> NO COLORS | ||
$ FORCE_COLOR=1 node app.js > log.txt #=> COLORS | ||
$ FORCE_COLOR=0 node app.js > log.txt #=> NO COLORS | ||
``` | ||
## API | ||
@@ -106,0 +116,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
19204
4.58%359
2.28%233
4.48%8
-11.11%