From c3d14f9ea81713a05d834434027a35de14c17751 Mon Sep 17 00:00:00 2001 From: Daniel Li Date: Thu, 20 Oct 2022 03:29:51 -0700 Subject: [PATCH 01/27] Update link to Truecolor in the readme (#573) --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index f18b2aa..4c620a2 100644 --- a/readme.md +++ b/readme.md @@ -281,7 +281,7 @@ console.log(foregroundColorNames.includes('pink')); ## 256 and Truecolor color support -Chalk supports 256 colors and [Truecolor](https://gist.github.com/XVilka/8346728) (16 million colors) on supported terminal apps. +Chalk supports 256 colors and [Truecolor](https://github.com/termstandard/colors) (16 million colors) on supported terminal apps. Colors are downsampled from 16 million RGB values to an ANSI color format that is supported by the terminal emulator (or by specifying `{level: n}` as a Chalk option). For example, Chalk configured to run at level 1 (basic color support) will downsample an RGB value of #FF0000 (red) to 31 (ANSI escape for red). From 79c56dfc1ea57b6762984aac86ab89acd6a9bc2c Mon Sep 17 00:00:00 2001 From: LitoMore Date: Mon, 31 Oct 2022 00:54:53 +0800 Subject: [PATCH 02/27] Update Replit badge (#576) --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 4c620a2..a3e14ce 100644 --- a/readme.md +++ b/readme.md @@ -12,7 +12,7 @@ [![Coverage Status](https://codecov.io/gh/chalk/chalk/branch/main/graph/badge.svg)](https://codecov.io/gh/chalk/chalk) [![npm dependents](https://badgen.net/npm/dependents/chalk)](https://www.npmjs.com/package/chalk?activeTab=dependents) [![Downloads](https://badgen.net/npm/dt/chalk)](https://www.npmjs.com/package/chalk) -[![run on repl.it](https://img.shields.io/badge/Run_on_Replit-130f26?logo=replit&logoColor=white)](https://repl.it/github/chalk/chalk) +[![run on repl.it](https://img.shields.io/badge/Run_on_Replit-f26207?logo=replit&logoColor=white)](https://repl.it/github/chalk/chalk) ![](media/screenshot.png) From a027e3c1e0fa8dcd850e20b7a99e73a5278e8f9a Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Thu, 17 Nov 2022 01:56:01 +0700 Subject: [PATCH 03/27] Minor tweaks --- .github/workflows/main.yml | 1 - examples/rainbow.js | 8 +++----- package.json | 2 +- readme.md | 12 ------------ source/vendor/supports-color/index.js | 7 +++++-- 5 files changed, 9 insertions(+), 21 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5cd8789..10bb5ee 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,7 +13,6 @@ jobs: - 18 - 16 - 14 - - 12 steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 diff --git a/examples/rainbow.js b/examples/rainbow.js index 3501dab..71e3c37 100644 --- a/examples/rainbow.js +++ b/examples/rainbow.js @@ -33,8 +33,6 @@ async function animateString(string) { } } -(async () => { - console.log(); - await animateString('We hope you enjoy Chalk! <3'); - console.log(); -})(); +console.log(); +await animateString('We hope you enjoy Chalk! <3'); +console.log(); diff --git a/package.json b/package.json index cc07db0..8f55398 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "log-update": "^5.0.0", "matcha": "^0.7.0", "tsd": "^0.19.0", - "xo": "^0.52.4", + "xo": "^0.53.0", "yoctodelay": "^2.0.0" }, "xo": { diff --git a/readme.md b/readme.md index a3e14ce..93511c0 100644 --- a/readme.md +++ b/readme.md @@ -40,18 +40,6 @@

- -
- Doppler -
- All your environment variables, in one place -
- Stop struggling with scattered API keys, hacking together home-brewed tools, -
- and avoiding access controls. Keep your team and servers in sync with Doppler. -
-
-
Strapi diff --git a/source/vendor/supports-color/index.js b/source/vendor/supports-color/index.js index 55f813c..130c8b9 100644 --- a/source/vendor/supports-color/index.js +++ b/source/vendor/supports-color/index.js @@ -129,10 +129,13 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) { const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10); switch (env.TERM_PROGRAM) { - case 'iTerm.app': + case 'iTerm.app': { return version >= 3 ? 3 : 2; - case 'Apple_Terminal': + } + + case 'Apple_Terminal': { return 2; + } // No default } } From 7443e9faa05b470a8a53850c2ded16fa0810a407 Mon Sep 17 00:00:00 2001 From: idanran <96647698+idanran@users.noreply.github.com> Date: Fri, 9 Dec 2022 02:43:43 +0800 Subject: [PATCH 04/27] Update `supports-color` dependency (#579) --- source/vendor/supports-color/browser.js | 27 +++++++++++++++++-------- source/vendor/supports-color/index.d.ts | 12 +++++------ source/vendor/supports-color/index.js | 21 +++++++++++++------ 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/source/vendor/supports-color/browser.js b/source/vendor/supports-color/browser.js index 4e75e86..9fa6888 100644 --- a/source/vendor/supports-color/browser.js +++ b/source/vendor/supports-color/browser.js @@ -1,15 +1,26 @@ /* eslint-env browser */ -const isBlinkBasedBrowser = navigator.userAgentData - ? navigator.userAgentData.brands.some(({brand}) => brand === 'Chromium') - : /\b(Chrome|Chromium)\//.test(navigator.userAgent); +const level = (() => { + if (navigator.userAgentData) { + const brand = navigator.userAgentData.brands.find(({brand}) => brand === 'Chromium'); + if (brand && brand.version > 93) { + return 3; + } + } -const colorSupport = isBlinkBasedBrowser ? { - level: 1, + if (/\b(Chrome|Chromium)\//.test(navigator.userAgent)) { + return 1; + } + + return 0; +})(); + +const colorSupport = level !== 0 && { + level, hasBasic: true, - has256: false, - has16m: false, -} : false; + has256: level >= 2, + has16m: level >= 3, +}; const supportsColor = { stdout: colorSupport, diff --git a/source/vendor/supports-color/index.d.ts b/source/vendor/supports-color/index.d.ts index 98e3618..db44a78 100644 --- a/source/vendor/supports-color/index.d.ts +++ b/source/vendor/supports-color/index.d.ts @@ -1,13 +1,13 @@ -import {WriteStream} from 'node:tty'; +import type {WriteStream} from 'node:tty'; -export interface Options { +export type Options = { /** Whether `process.argv` should be sniffed for `--color` and `--no-color` flags. @default true */ readonly sniffFlags?: boolean; -} +}; /** Levels: @@ -21,7 +21,7 @@ export type ColorSupportLevel = 0 | 1 | 2 | 3; /** Detect whether the terminal supports color. */ -export interface ColorSupport { +export type ColorSupport = { /** The color level. */ @@ -41,11 +41,11 @@ export interface ColorSupport { Whether Truecolor 16 million colors are supported. */ has16m: boolean; -} +}; export type ColorInfo = ColorSupport | false; -export function createSupportsColor(stream: WriteStream, options?: Options): ColorInfo; +export function createSupportsColor(stream?: WriteStream, options?: Options): ColorInfo; declare const supportsColor: { stdout: ColorInfo; diff --git a/source/vendor/supports-color/index.js b/source/vendor/supports-color/index.js index 130c8b9..a7cea61 100644 --- a/source/vendor/supports-color/index.js +++ b/source/vendor/supports-color/index.js @@ -3,7 +3,7 @@ import os from 'node:os'; import tty from 'node:tty'; // From: https://github.com/sindresorhus/has-flag/blob/main/index.js -function hasFlag(flag, argv = process.argv) { +function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process.argv) { const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--'); const position = argv.indexOf(prefix + flag); const terminatorPosition = argv.indexOf('--'); @@ -80,6 +80,12 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) { } } + // Check for Azure DevOps pipelines. + // Has to be above the `!streamIsTTY` check. + if ('TF_BUILD' in env && 'AGENT_NAME' in env) { + return 1; + } + if (haveStream && !streamIsTTY && forceColor === undefined) { return 0; } @@ -105,7 +111,11 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) { } if ('CI' in env) { - if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') { + if ('GITHUB_ACTIONS' in env) { + return 3; + } + + if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') { return 1; } @@ -116,12 +126,11 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) { return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0; } - // Check for Azure DevOps pipelines - if ('TF_BUILD' in env && 'AGENT_NAME' in env) { - return 1; + if (env.COLORTERM === 'truecolor') { + return 3; } - if (env.COLORTERM === 'truecolor') { + if (env.TERM === 'xterm-kitty') { return 3; } From a370f468a43999e4397094ff5c3d17aadcc4860e Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Thu, 8 Dec 2022 19:46:06 +0100 Subject: [PATCH 05/27] 5.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8f55398..ddcf758 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chalk", - "version": "5.1.2", + "version": "5.2.0", "description": "Terminal string styling done right", "license": "MIT", "repository": "chalk/chalk", From 29b856959f4bee5a514c7ed48a1f6879686eadf2 Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 29 Jun 2023 12:47:28 +0200 Subject: [PATCH 06/27] Update `supports-color` to 9.4.0 (#603) Co-authored-by: Sindre Sorhus --- source/vendor/supports-color/browser.js | 2 +- source/vendor/supports-color/index.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/source/vendor/supports-color/browser.js b/source/vendor/supports-color/browser.js index 9fa6888..1ffde64 100644 --- a/source/vendor/supports-color/browser.js +++ b/source/vendor/supports-color/browser.js @@ -3,7 +3,7 @@ const level = (() => { if (navigator.userAgentData) { const brand = navigator.userAgentData.brands.find(({brand}) => brand === 'Chromium'); - if (brand && brand.version > 93) { + if (brand?.version > 93) { return 3; } } diff --git a/source/vendor/supports-color/index.js b/source/vendor/supports-color/index.js index a7cea61..4ce0a2d 100644 --- a/source/vendor/supports-color/index.js +++ b/source/vendor/supports-color/index.js @@ -3,6 +3,7 @@ import os from 'node:os'; import tty from 'node:tty'; // From: https://github.com/sindresorhus/has-flag/blob/main/index.js +/// function hasFlag(flag, argv = globalThis.Deno?.args ?? process.argv) { function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process.argv) { const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--'); const position = argv.indexOf(prefix + flag); @@ -111,7 +112,7 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) { } if ('CI' in env) { - if ('GITHUB_ACTIONS' in env) { + if ('GITHUB_ACTIONS' in env || 'GITEA_ACTIONS' in env) { return 3; } From df0e69df5129a5e19acc7ae0199319a104d0e6cc Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Thu, 29 Jun 2023 12:49:29 +0200 Subject: [PATCH 07/27] Fix CI --- package.json | 3 ++- source/vendor/supports-color/browser.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ddcf758..0d05e4e 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,8 @@ "unicorn/prefer-string-slice": "off", "@typescript-eslint/consistent-type-imports": "off", "@typescript-eslint/consistent-type-exports": "off", - "@typescript-eslint/consistent-type-definitions": "off" + "@typescript-eslint/consistent-type-definitions": "off", + "unicorn/expiring-todo-comments": "off" } }, "c8": { diff --git a/source/vendor/supports-color/browser.js b/source/vendor/supports-color/browser.js index 1ffde64..9fa6888 100644 --- a/source/vendor/supports-color/browser.js +++ b/source/vendor/supports-color/browser.js @@ -3,7 +3,7 @@ const level = (() => { if (navigator.userAgentData) { const brand = navigator.userAgentData.brands.find(({brand}) => brand === 'Chromium'); - if (brand?.version > 93) { + if (brand && brand.version > 93) { return 3; } } From 5aafc0af74d06c89a2a4567aaf9d84d44af4a3aa Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Thu, 29 Jun 2023 12:52:59 +0200 Subject: [PATCH 08/27] Add `sideEffects` field to package.json Fixes #585 --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 0d05e4e..7447a1f 100644 --- a/package.json +++ b/package.json @@ -61,6 +61,7 @@ "xo": "^0.53.0", "yoctodelay": "^2.0.0" }, + "sideEffects": false, "xo": { "rules": { "unicorn/prefer-string-slice": "off", From 72c742d4716b1f94bb24bbda86d96fbb247ca646 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Thu, 29 Jun 2023 12:56:55 +0200 Subject: [PATCH 09/27] 5.3.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7447a1f..3c50010 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chalk", - "version": "5.2.0", + "version": "5.3.0", "description": "Terminal string styling done right", "license": "MIT", "repository": "chalk/chalk", From f399cd0ff69841e88cca89d43a49f1cc9ba2efd5 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Thu, 29 Jun 2023 14:45:41 +0200 Subject: [PATCH 10/27] Meta tweaks --- readme.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/readme.md b/readme.md index 93511c0..b4e0849 100644 --- a/readme.md +++ b/readme.md @@ -51,14 +51,6 @@

- -
- StackAid -
- Fund your open source dependencies -
-
-

From f7b29ae8ef4fd2048e08aa361778d290ed10ce7a Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Wed, 16 Aug 2023 12:14:40 +0200 Subject: [PATCH 11/27] Remove repl.it badge Fixes #587 --- readme.md | 1 - 1 file changed, 1 deletion(-) diff --git a/readme.md b/readme.md index b4e0849..7cd796d 100644 --- a/readme.md +++ b/readme.md @@ -12,7 +12,6 @@ [![Coverage Status](https://codecov.io/gh/chalk/chalk/branch/main/graph/badge.svg)](https://codecov.io/gh/chalk/chalk) [![npm dependents](https://badgen.net/npm/dependents/chalk)](https://www.npmjs.com/package/chalk?activeTab=dependents) [![Downloads](https://badgen.net/npm/dt/chalk)](https://www.npmjs.com/package/chalk) -[![run on repl.it](https://img.shields.io/badge/Run_on_Replit-f26207?logo=replit&logoColor=white)](https://repl.it/github/chalk/chalk) ![](media/screenshot.png) From 2db3c7701ec87a1d88b3c636dd46d3d985304bce Mon Sep 17 00:00:00 2001 From: Edwin Kofler Date: Fri, 5 Jan 2024 17:08:07 -0800 Subject: [PATCH 12/27] Remove .replit file (#622) --- .replit | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 .replit diff --git a/.replit b/.replit deleted file mode 100644 index cf3930d..0000000 --- a/.replit +++ /dev/null @@ -1,2 +0,0 @@ -language = "nodejs" -run = "cd examples && node rainbow" From 386909ee0bfe4346d04e3eeba712f0db597c038d Mon Sep 17 00:00:00 2001 From: Richie Bendall Date: Sat, 20 Jan 2024 03:36:11 +1300 Subject: [PATCH 13/27] Tweak example (#623) --- examples/rainbow.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/rainbow.js b/examples/rainbow.js index 71e3c37..cfc4cef 100644 --- a/examples/rainbow.js +++ b/examples/rainbow.js @@ -1,6 +1,6 @@ +import {setTimeout as delay} from 'node:timers/promises'; import convertColor from 'color-convert'; import updateLog from 'log-update'; -import delay from 'yoctodelay'; import chalk from '../source/index.js'; const ignoreChars = /[^!-~]/g; From 795273f17a94329c7a46247d8277f9afc2f0a6d9 Mon Sep 17 00:00:00 2001 From: Lightner <79603731+LightnerDev@users.noreply.github.com> Date: Fri, 5 Jul 2024 05:41:35 -0500 Subject: [PATCH 14/27] Update dependents number in readme (#629) --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 7cd796d..d52688b 100644 --- a/readme.md +++ b/readme.md @@ -68,7 +68,7 @@ - Doesn't extend `String.prototype` - Clean and focused - Actively maintained -- [Used by ~86,000 packages](https://www.npmjs.com/browse/depended/chalk) as of October 4, 2022 +- [Used by ~115,000 packages](https://www.npmjs.com/browse/depended/chalk) as of July 4, 2024 ## Install From 77126fba1328bb1b5524c45164d0a44074d5179d Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Sat, 11 Nov 2023 19:54:30 +0700 Subject: [PATCH 15/27] Meta tweaks --- .github/workflows/main.yml | 4 ++-- examples/rainbow.js | 2 +- package.json | 4 ++-- readme.md | 42 -------------------------------------- source/index.d.ts | 7 ++++++- source/index.test-d.ts | 21 ++++++++++++++++--- 6 files changed, 29 insertions(+), 51 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 10bb5ee..d588995 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,8 +14,8 @@ jobs: - 16 - 14 steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - run: npm install diff --git a/examples/rainbow.js b/examples/rainbow.js index cfc4cef..5b2b1d2 100644 --- a/examples/rainbow.js +++ b/examples/rainbow.js @@ -10,7 +10,7 @@ function rainbow(string, offset) { return string; } - const hueStep = 360 / string.replace(ignoreChars, '').length; + const hueStep = 360 / string.replaceAll(ignoreChars, '').length; let hue = offset % 360; const characters = []; diff --git a/package.json b/package.json index 3c50010..4eb7f11 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ } }, "types": "./source/index.d.ts", + "sideEffects": false, "engines": { "node": "^12.17.0 || ^14.13 || >=16.0.0" }, @@ -58,10 +59,9 @@ "log-update": "^5.0.0", "matcha": "^0.7.0", "tsd": "^0.19.0", - "xo": "^0.53.0", + "xo": "^0.57.0", "yoctodelay": "^2.0.0" }, - "sideEffects": false, "xo": { "rules": { "unicorn/prefer-string-slice": "off", diff --git a/readme.md b/readme.md index d52688b..6aa0119 100644 --- a/readme.md +++ b/readme.md @@ -15,48 +15,6 @@ ![](media/screenshot.png) -
- ---- - -
-

-

- - Sindre Sorhus' open source work is supported by the community on GitHub Sponsors - -

- Special thanks to: -
-
- - - -
-
- - - -
-
- -
- Strapi -
- Strapi is the leading open-source headless CMS. -
- It’s 100% JavaScript, fully customizable, and developer-first. -
-
-
-
-

-
- ---- - -
- ## Highlights - Expressive API diff --git a/source/index.d.ts b/source/index.d.ts index b0cd2ae..8295d92 100644 --- a/source/index.d.ts +++ b/source/index.d.ts @@ -1,7 +1,12 @@ // TODO: Make it this when TS suports that. // import {ModifierName, ForegroundColor, BackgroundColor, ColorName} from '#ansi-styles'; // import {ColorInfo, ColorSupportLevel} from '#supports-color'; -import {ModifierName, ForegroundColorName, BackgroundColorName, ColorName} from './vendor/ansi-styles/index.js'; +import { + ModifierName, + ForegroundColorName, + BackgroundColorName, + ColorName, +} from './vendor/ansi-styles/index.js'; import {ColorInfo, ColorSupportLevel} from './vendor/supports-color/index.js'; export interface Options { diff --git a/source/index.test-d.ts b/source/index.test-d.ts index e729675..92da39d 100644 --- a/source/index.test-d.ts +++ b/source/index.test-d.ts @@ -1,7 +1,22 @@ -import {expectType, expectAssignable, expectError, expectDeprecated} from 'tsd'; +import { + expectType, + expectAssignable, + expectError, + expectDeprecated, +} from 'tsd'; import chalk, { - Chalk, ChalkInstance, ColorInfo, ColorSupport, ColorSupportLevel, chalkStderr, supportsColor, supportsColorStderr, - ModifierName, ForegroundColorName, BackgroundColorName, ColorName, + Chalk, + ChalkInstance, + ColorInfo, + ColorSupport, + ColorSupportLevel, + chalkStderr, + supportsColor, + supportsColorStderr, + ModifierName, + ForegroundColorName, + BackgroundColorName, + ColorName, Modifiers, } from './index.js'; From 4a10354857ba6d7932dad5fa6ef2e021c4ed47fb Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Tue, 13 Aug 2024 14:49:54 +0200 Subject: [PATCH 16/27] Add FAQ to readme --- readme.md | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 6aa0119..455efaa 100644 --- a/readme.md +++ b/readme.md @@ -15,6 +15,11 @@ ![](media/screenshot.png) +## Info + +- [Why not switch to a smaller coloring package?](https://github.com/chalk/chalk?tab=readme-ov-file#why-not-switch-to-a-smaller-coloring-package) +- See [yoctocolors](https://github.com/sindresorhus/yoctocolors) for a smaller alternative + ## Highlights - Expressive API @@ -246,9 +251,25 @@ Since Chrome 69, ANSI escape codes are natively supported in the developer conso If you're on Windows, do yourself a favor and use [Windows Terminal](https://github.com/microsoft/terminal) instead of `cmd.exe`. -## Origin story +## FAQ -[colors.js](https://github.com/Marak/colors.js) used to be the most popular string styling module, but it has serious deficiencies like extending `String.prototype` which causes all kinds of [problems](https://github.com/yeoman/yo/issues/68) and the package is unmaintained. Although there are other packages, they either do too much or not enough. Chalk is a clean and focused alternative. +### Why not switch to a smaller coloring package? + +Chalk may be larger, but there is a reason for that. It offers a more user-friendly API, well-documented types, supports millions of colors, and covers edge cases that smaller alternatives miss. Chalk is mature, reliable, and built to last. + +But beyond the technical aspects, there's something more critical: trust and long-term maintenance. I have been active in open source for over a decade, and I'm committed to keeping Chalk maintained. Smaller packages might seem appealing now, but there's no guarantee they will be around for the long term, or that they won't become malicious over time. + +Chalk is also likely already in your dependency tree (since 100K+ packages depend on it), so switching won’t save space—in fact, it might increase it. npm deduplicates dependencies, so multiple Chalk instances turn into one, but adding another package alongside it will increase your overall size. + +If the goal is to clean up the ecosystem, switching away from Chalk won’t even make a dent. The real problem lies with packages that have very deep dependency trees (for example, those including a lot of polyfills). Chalk has no dependencies. It's better to focus on impactful changes rather than minor optimizations. + +If absolute package size is important to you, I also maintain [yoctocolors](https://github.com/sindresorhus/yoctocolors), one of the smallest color packages out there. + +*\- [Sindre](https://github.com/sindresorhus)* + +### But the smaller coloring package has benchmarks showing it is faster + +[Micro-benchmarks are flawed](https://sindresorhus.com/blog/micro-benchmark-fallacy) because they measure performance in unrealistic, isolated scenarios, often giving a distorted view of real-world performance. Don't believe marketing fluff. All the coloring packages are more than fast enough. ## Related From f8381204fb096207074089f5ab265fffff6bc341 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Wed, 18 Dec 2024 18:57:37 +0100 Subject: [PATCH 17/27] Update `CIRCLECI` environments to return level 3 color support https://github.com/chalk/supports-color/commit/89a52f4a8e3f7606c27810a8f182394d333a844f --- source/vendor/supports-color/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/vendor/supports-color/index.js b/source/vendor/supports-color/index.js index 4ce0a2d..1388372 100644 --- a/source/vendor/supports-color/index.js +++ b/source/vendor/supports-color/index.js @@ -112,11 +112,11 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) { } if ('CI' in env) { - if ('GITHUB_ACTIONS' in env || 'GITEA_ACTIONS' in env) { + if (['GITHUB_ACTIONS', 'GITEA_ACTIONS', 'CIRCLECI'].some(key => key in env)) { return 3; } - if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') { + if (['TRAVIS', 'APPVEYOR', 'GITLAB_CI', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') { return 1; } From 83acfcf8cb17437b63beceb027180399da74f0a7 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Wed, 18 Dec 2024 18:59:38 +0100 Subject: [PATCH 18/27] 5.4.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4eb7f11..3fd5094 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chalk", - "version": "5.3.0", + "version": "5.4.0", "description": "Terminal string styling done right", "license": "MIT", "repository": "chalk/chalk", From fc809b686d5048d56fec3a5d96d1ad57dee193bf Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Wed, 18 Dec 2024 19:10:23 +0100 Subject: [PATCH 19/27] Readme tweak --- readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readme.md b/readme.md index 455efaa..5754e7c 100644 --- a/readme.md +++ b/readme.md @@ -289,6 +289,8 @@ If absolute package size is important to you, I also maintain [yoctocolors](http - [chalk-pipe](https://github.com/LitoMore/chalk-pipe) - Create chalk style schemes with simpler style strings - [terminal-link](https://github.com/sindresorhus/terminal-link) - Create clickable links in the terminal +*(Not accepting additional entries)* + ## Maintainers - [Sindre Sorhus](https://github.com/sindresorhus) From 4ebb62d1ca70c122674558a88932ddf6545fe9ef Mon Sep 17 00:00:00 2001 From: Edwin Kofler Date: Sat, 21 Dec 2024 09:01:49 -0800 Subject: [PATCH 20/27] Fix `navigator` not defined `ReferenceError` (#642) --- source/vendor/supports-color/browser.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/vendor/supports-color/browser.js b/source/vendor/supports-color/browser.js index 9fa6888..fbb6ce0 100644 --- a/source/vendor/supports-color/browser.js +++ b/source/vendor/supports-color/browser.js @@ -1,14 +1,18 @@ /* eslint-env browser */ const level = (() => { - if (navigator.userAgentData) { + if (!('navigator' in globalThis)) { + return 0; + } + + if (globalThis.navigator.userAgentData) { const brand = navigator.userAgentData.brands.find(({brand}) => brand === 'Chromium'); if (brand && brand.version > 93) { return 3; } } - if (/\b(Chrome|Chromium)\//.test(navigator.userAgent)) { + if (/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)) { return 1; } From 5dbc1e2633f3874f43c144fa4919934bc934c495 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Sat, 21 Dec 2024 18:04:25 +0100 Subject: [PATCH 21/27] 5.4.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3fd5094..23b4ce3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chalk", - "version": "5.4.0", + "version": "5.4.1", "description": "Terminal string styling done right", "license": "MIT", "repository": "chalk/chalk", From 79ee2d386c58ae3863c28a01f5f86b04c78adfc1 Mon Sep 17 00:00:00 2001 From: Brice <59537185+rhodes-b@users.noreply.github.com> Date: Sun, 3 Aug 2025 18:14:54 -0500 Subject: [PATCH 22/27] Make Ghostty terminal use true color (#653) --- source/vendor/supports-color/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/vendor/supports-color/index.js b/source/vendor/supports-color/index.js index 1388372..0e130a1 100644 --- a/source/vendor/supports-color/index.js +++ b/source/vendor/supports-color/index.js @@ -135,6 +135,10 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) { return 3; } + if (env.TERM === 'xterm-ghostty') { + return 3; + } + if ('TERM_PROGRAM' in env) { const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10); From 67db246ae0a2bbcc57c190d641c5d767e5275160 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Mon, 4 Aug 2025 01:17:43 +0200 Subject: [PATCH 23/27] 5.5.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 23b4ce3..e431a64 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chalk", - "version": "5.4.1", + "version": "5.5.0", "description": "Terminal string styling done right", "license": "MIT", "repository": "chalk/chalk", From a8f5bf7a6733b1e2a356d5cccea6a45d80cf16c7 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Sun, 17 Aug 2025 14:25:09 +0700 Subject: [PATCH 24/27] Make WezTerm terminal use true color --- source/vendor/supports-color/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/vendor/supports-color/index.js b/source/vendor/supports-color/index.js index 0e130a1..265d7f8 100644 --- a/source/vendor/supports-color/index.js +++ b/source/vendor/supports-color/index.js @@ -139,6 +139,10 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) { return 3; } + if (env.TERM === 'wezterm') { + return 3; + } + if ('TERM_PROGRAM' in env) { const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10); From 5c91505e184aff4609c0a7fb235770c2f71db4a3 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Sun, 17 Aug 2025 14:26:22 +0700 Subject: [PATCH 25/27] 5.6.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e431a64..910d7fa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chalk", - "version": "5.5.0", + "version": "5.6.0", "description": "Terminal string styling done right", "license": "MIT", "repository": "chalk/chalk", From 51557784b829c87ff8d138206598764f2eb957b1 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Mon, 8 Sep 2025 21:47:34 +0700 Subject: [PATCH 26/27] 5.6.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 910d7fa..c9e0dc5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chalk", - "version": "5.6.0", + "version": "5.6.2", "description": "Terminal string styling done right", "license": "MIT", "repository": "chalk/chalk", From aa06bb5ac3f14df9fda8cfb54274dfc165ddfdef Mon Sep 17 00:00:00 2001 From: Mohamed Hamed <79021260+mdhamed238@users.noreply.github.com> Date: Tue, 27 Jan 2026 07:30:36 +0100 Subject: [PATCH 27/27] Fix typos (#664) --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 5754e7c..ce1f3f3 100644 --- a/readme.md +++ b/readme.md @@ -178,10 +178,10 @@ console.log(foregroundColorNames.includes('pink')); - `italic` - Make the text italic. *(Not widely supported)* - `underline` - Put a horizontal line below the text. *(Not widely supported)* - `overline` - Put a horizontal line above the text. *(Not widely supported)* -- `inverse`- Invert background and foreground colors. +- `inverse` - Invert background and foreground colors. - `hidden` - Print the text but make it invisible. - `strikethrough` - Puts a horizontal line through the center of the text. *(Not widely supported)* -- `visible`- Print the text only when Chalk has a color level above zero. Can be useful for things that are purely cosmetic. +- `visible` - Print the text only when Chalk has a color level above zero. Can be useful for things that are purely cosmetic. ### Colors