diff --git a/README.md b/README.md index 42978b7..5a39679 100644 --- a/README.md +++ b/README.md @@ -588,6 +588,40 @@ $ FORCE_COLOR=0 node app.js # force disable colors, non colored output $ FORCE_COLOR=1 node app.js > log.txt # force enable colors, output in file with ANSI codes ``` +#### How to force enable 256 colors + +If your environment supports 256 colors, but `ansis` detects only 16 or mono, +you can manually set the `TERM` variable with standard values: `screen-256color` or `xterm-256color`. + +You can set the variable in CLI: + +``` +TERM=screen-256color node script.js +``` + +or directly in your script: + +```js +process.env.TERM = 'screen-256color'; +``` + +#### How to force enable truecolor + +If your environment supports truecolor, but `ansis` detects only 256, 16 or mono, +you can manually set the `COLORTERM` variable with standard values: `truecolor` or `24bit`. + +You can set the variable in CLI: + +``` +COLORTERM=truecolor node script.js +``` + +or directly in your script: + +```js +process.env.COLORTERM = 'truecolor'; +``` + ### CLI arguments Use arguments `--no-color` or `--color=false` to disable colors and `--color` to enable ones. @@ -682,18 +716,18 @@ npm run compare [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/edit/compare-colorize-libraries?file=index.js) -| Library
________________
- named import
- naming colors | ANSI 16 colors | ANSI 256
colors | True
Color | Chained
syntax | Nested
template strings | New
Line | Fallback to colors | Supports
ENV vars
CLI flags | -|:-------------------------------------------------------------------------------|:----------------:|:------------------:|:-------------:|:-----------------:|:--------------------------:|:-----------:|---------------------|:---------------------------------------------------------| -| [`ansis`][ansis]
`✅ named import`
`✅ standard` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | →256
→16
→b&w | `NO_COLOR`
`FORCE_COLOR`
`--no-color`
`--color` | -| [`chalk`][chalk]
`❌ named import`
`✅ standard` | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | →256
→16
→b&w | `NO_COLOR`
`FORCE_COLOR`
`--no-color`
`--color` | -| [`kolorist`][kolorist]
`✅ named import`
`❌ standard` | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | →256
→b&w | `NO_COLOR`
`FORCE_COLOR` | -| [`cli-color`][cli-color]
`❌ named import`
`✅ standard` | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ | →16
→b&w | `NO_COLOR` | -| [`colors-cli`][colors-cli]
`❌ named import`
`❌ standard` | ✅ | ✅ | ❌ | ✅ | ❌ | ✅ | →b&w | `--no-color`
`--color` | -| [`colors.js`][colors.js]
`❌ named import`
`❌ standard` | ✅ | ❌ | ❌ | ✅ | ❌ | ✅ | →b&w | `FORCE_COLOR`
`--no-color`
`--color` | -| [`ansi-colors`][ansi-colors]
`❌ named import`
`✅ standard` | ✅ | ❌ | ❌ | ✅ | ❌ | ✅ | ❌ | `FORCE_COLOR` | -| [`colorette`][colorette]
`✅ named import`
`✅ standard` | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | →b&w | `NO_COLOR`
`FORCE_COLOR`
`--no-color`
`--color` | -| [`kleur`][kleur]
`✅ named import`
`✅ standard` | ❌
`8` colors | ❌ | ❌ | ✅ | ❌ | ❌ | →b&w | `NO_COLOR`
`FORCE_COLOR` | -| [`picocolors`][picocolors]
`❌ named import`
`✅ standard` | ❌
`8` colors | ❌ | ❌ | ❌ | ❌ | ❌ | →b&w | `NO_COLOR`
`FORCE_COLOR`
`--no-color`
`--color` | +| Library
________________
- named import
- naming colors | ANSI 16 colors | ANSI 256
colors | True
Color | Chained
syntax | Nested
template strings | New
Line | Fallback to colors | Supports
ENV vars
CLI flags | +|:-------------------------------------------------------------------------------|:-----------------:|:------------------:|:-------------:|:-----------------:|:--------------------------:|:-----------:|---------------------|:---------------------------------------------------------| +| [`ansis`][ansis]
`✅ named import`
`✅ standard` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | →256
→16
→b&w | `NO_COLOR`
`FORCE_COLOR`
`--no-color`
`--color` | +| [`chalk`][chalk]
`❌ named import`
`✅ standard` | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | →256
→16
→b&w | `NO_COLOR`
`FORCE_COLOR`
`--no-color`
`--color` | +| [`kolorist`][kolorist]
`✅ named import`
`❌ standard` | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | →256
→b&w | `NO_COLOR`
`FORCE_COLOR` | +| [`cli-color`][cli-color]
`❌ named import`
`✅ standard` | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ | →16
→b&w | `NO_COLOR` | +| [`colors-cli`][colors-cli]
`❌ named import`
`❌ standard` | ✅ | ✅ | ❌ | ✅ | ❌ | ✅ | →b&w | `--no-color`
`--color` | +| [`colors.js`][colors.js]
`❌ named import`
`❌ standard` | ✅ | ❌ | ❌ | ✅ | ❌ | ✅ | →b&w | `FORCE_COLOR`
`--no-color`
`--color` | +| [`ansi-colors`][ansi-colors]
`❌ named import`
`✅ standard` | ✅ | ❌ | ❌ | ✅ | ❌ | ✅ | ❌ | `FORCE_COLOR` | +| [`colorette`][colorette]
`✅ named import`
`✅ standard` | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | →b&w | `NO_COLOR`
`FORCE_COLOR`
`--no-color`
`--color` | +| [`picocolors`][picocolors]
`❌ named import`
`✅ standard` | ✅
since v1.1.0 | ❌ | ❌ | ❌ | ❌ | ❌ | →b&w | `NO_COLOR`
`FORCE_COLOR`
`--no-color`
`--color` | +| [`kleur`][kleur]
`✅ named import`
`✅ standard` | ❌
`8` colors | ❌ | ❌ | ✅ | ❌ | ❌ | →b&w | `NO_COLOR`
`FORCE_COLOR` | > **Note** > @@ -742,16 +776,16 @@ npm run compare | Npm package | Require size | Install size | Download size | |:-----------------------------|-------------:|-------------------------------:|----------------------------------------------------------------------:| +| [`picocolors`][picocolors] | 2.6 kB | [11.4 kB][npm-picocolors] | [2.6 kB](https://arve0.github.io/npm-download-size/#picocolors) | +| [`kleur`][kleur] | 2.7 kB | [20.3 kB][npm-kleur] | [6.0 kB](https://arve0.github.io/npm-download-size/#kleur) | | [`ansis`][ansis] | 3.4 kB | [11.4 kB][npm-ansis] | [4.6 kB](https://arve0.github.io/npm-download-size/#ansis) | -| [`chalk`][chalk] | 16.4 kB | [43.7 kB][npm-chalk] | [13.1 kB](https://arve0.github.io/npm-download-size/#chalk) | +| [`colorette`][colorette] | 3.4 kB | [17.0 kB][npm-colorette] | [4.9 kB](https://arve0.github.io/npm-download-size/#colorette) | +| [`ansi-colors`][ansi-colors] | 5.8 kB | [26.1 kB][npm-ansi-colors] | [8.5 kB](https://arve0.github.io/npm-download-size/#ansi-colors) | | [`kolorist`][kolorist] | 6.8 kB | [51.0 kB][npm-kolorist] | [8.7 kB](https://arve0.github.io/npm-download-size/#kolorist) | -| [`cli-color`][cli-color] | 12.1 kB | [39.6 (754 kB)][npm-cli-color] | [13.8 (216 kB)](https://arve0.github.io/npm-download-size/#cli-color) | | [`colors-cli`][colors-cli] | 8.7 kB | [511.0 kB][npm-colors-cli] | [361.7 kB](https://arve0.github.io/npm-download-size/#colors-cli) | +| [`cli-color`][cli-color] | 12.1 kB | [39.6 (754 kB)][npm-cli-color] | [13.8 (216 kB)](https://arve0.github.io/npm-download-size/#cli-color) | +| [`chalk`][chalk] | 16.4 kB | [43.7 kB][npm-chalk] | [13.1 kB](https://arve0.github.io/npm-download-size/#chalk) | | [`colors.js`][colors.js] | 18.1 kB | [39.5 kB][npm-colors.js] | [11.0 kB](https://arve0.github.io/npm-download-size/#colors) | -| [`ansi-colors`][ansi-colors] | 5.8 kB | [26.1 kB][npm-ansi-colors] | [8.5 kB](https://arve0.github.io/npm-download-size/#ansi-colors) | -| [`kleur`][kleur] | 2.7 kB | [20.3 kB][npm-kleur] | [6.0 kB](https://arve0.github.io/npm-download-size/#kleur) | -| [`colorette`][colorette] | 3.4 kB | [17.0 kB][npm-colorette] | [4.9 kB](https://arve0.github.io/npm-download-size/#colorette) | -| [`picocolors`][picocolors] | 2.1 kB | [5.1 kB][npm-picocolors] | [2.4 kB](https://arve0.github.io/npm-download-size/#picocolors) | **Require size**: The size of distributed code that will be loaded via `require` or `import` into your app.\ **Install size:** The unpacked size of the npm package in the `node_modules/` directory, `(incl. dependencies)`.\ diff --git a/bench/package.json b/bench/package.json index a82ddeb..c6d4366 100644 --- a/bench/package.json +++ b/bench/package.json @@ -19,7 +19,7 @@ "colors-cli": "1.0.33", "kleur": "4.1.5", "kolorist": "1.8.0", - "picocolors": "1.0.0", - "vitest": "^1.4.0" + "picocolors": "1.1.0", + "vitest": "^2.1.1" } } diff --git a/compare/package.json b/compare/package.json index 5b55e84..2b14d87 100644 --- a/compare/package.json +++ b/compare/package.json @@ -15,6 +15,6 @@ "colors-cli": "1.0.33", "kleur": "4.1.5", "kolorist": "1.8.0", - "picocolors": "1.0.0" + "picocolors": "1.1.0" } } diff --git a/package.json b/package.json index 305ed49..6cbfb88 100644 --- a/package.json +++ b/package.json @@ -87,17 +87,17 @@ "node": ">=15" }, "devDependencies": { - "@rollup/plugin-replace": "^5.0.5", + "@rollup/plugin-replace": "^6.0.1", "@rollup/plugin-terser": "^0.4.4", "@types/node": "^20.11.30", - "@vitest/coverage-v8": "^1.4.0", + "@vitest/coverage-v8": "^2.1.1", "ansis": "file:dist", - "prettier": "^3.2.5", - "rollup": "^4.13.0", + "prettier": "^3.3.3", + "rollup": "^4.22.5", "rollup-plugin-cleanup": "^3.2.1", "rollup-plugin-copy": "^3.5.0", - "rollup-plugin-dts": "^6.1.0", - "terser": "^5.30.0", - "vitest": "^1.4.0" + "rollup-plugin-dts": "^6.1.1", + "terser": "^5.34.1", + "vitest": "^2.1.1" } } diff --git a/test/env/color-space.truecolor.js b/test/env/color-space.truecolor.js index cfdbb42..85e2bc3 100644 --- a/test/env/color-space.truecolor.js +++ b/test/env/color-space.truecolor.js @@ -1,2 +1,2 @@ -// set env variable to simulate truecolor color space -process.env.FORCE_COLOR = 'true'; \ No newline at end of file +// set env variable to simulate truecolor color space in any test environment +process.env.COLORTERM = 'truecolor'; \ No newline at end of file