Compare commits
27 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa06bb5ac3 | ||
|
|
51557784b8 | ||
|
|
5c91505e18 | ||
|
|
a8f5bf7a67 | ||
|
|
67db246ae0 | ||
|
|
79ee2d386c | ||
|
|
5dbc1e2633 | ||
|
|
4ebb62d1ca | ||
|
|
fc809b686d | ||
|
|
83acfcf8cb | ||
|
|
f8381204fb | ||
|
|
4a10354857 | ||
|
|
77126fba13 | ||
|
|
795273f17a | ||
|
|
386909ee0b | ||
|
|
2db3c7701e | ||
|
|
f7b29ae8ef | ||
|
|
f399cd0ff6 | ||
|
|
72c742d471 | ||
|
|
5aafc0af74 | ||
|
|
df0e69df51 | ||
|
|
29b856959f | ||
|
|
a370f468a4 | ||
|
|
7443e9faa0 | ||
|
|
a027e3c1e0 | ||
|
|
79c56dfc1e | ||
|
|
c3d14f9ea8 |
10 changed files with 121 additions and 108 deletions
5
.github/workflows/main.yml
vendored
5
.github/workflows/main.yml
vendored
|
|
@ -13,10 +13,9 @@ jobs:
|
||||||
- 18
|
- 18
|
||||||
- 16
|
- 16
|
||||||
- 14
|
- 14
|
||||||
- 12
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
- run: npm install
|
- run: npm install
|
||||||
|
|
|
||||||
2
.replit
2
.replit
|
|
@ -1,2 +0,0 @@
|
||||||
language = "nodejs"
|
|
||||||
run = "cd examples && node rainbow"
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
|
import {setTimeout as delay} from 'node:timers/promises';
|
||||||
import convertColor from 'color-convert';
|
import convertColor from 'color-convert';
|
||||||
import updateLog from 'log-update';
|
import updateLog from 'log-update';
|
||||||
import delay from 'yoctodelay';
|
|
||||||
import chalk from '../source/index.js';
|
import chalk from '../source/index.js';
|
||||||
|
|
||||||
const ignoreChars = /[^!-~]/g;
|
const ignoreChars = /[^!-~]/g;
|
||||||
|
|
@ -10,7 +10,7 @@ function rainbow(string, offset) {
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const hueStep = 360 / string.replace(ignoreChars, '').length;
|
const hueStep = 360 / string.replaceAll(ignoreChars, '').length;
|
||||||
|
|
||||||
let hue = offset % 360;
|
let hue = offset % 360;
|
||||||
const characters = [];
|
const characters = [];
|
||||||
|
|
@ -33,8 +33,6 @@ async function animateString(string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(async () => {
|
console.log();
|
||||||
console.log();
|
await animateString('We hope you enjoy Chalk! <3');
|
||||||
await animateString('We hope you enjoy Chalk! <3');
|
console.log();
|
||||||
console.log();
|
|
||||||
})();
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "chalk",
|
"name": "chalk",
|
||||||
"version": "5.1.2",
|
"version": "5.6.2",
|
||||||
"description": "Terminal string styling done right",
|
"description": "Terminal string styling done right",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": "chalk/chalk",
|
"repository": "chalk/chalk",
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"types": "./source/index.d.ts",
|
"types": "./source/index.d.ts",
|
||||||
|
"sideEffects": false,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^12.17.0 || ^14.13 || >=16.0.0"
|
"node": "^12.17.0 || ^14.13 || >=16.0.0"
|
||||||
},
|
},
|
||||||
|
|
@ -58,7 +59,7 @@
|
||||||
"log-update": "^5.0.0",
|
"log-update": "^5.0.0",
|
||||||
"matcha": "^0.7.0",
|
"matcha": "^0.7.0",
|
||||||
"tsd": "^0.19.0",
|
"tsd": "^0.19.0",
|
||||||
"xo": "^0.52.4",
|
"xo": "^0.57.0",
|
||||||
"yoctodelay": "^2.0.0"
|
"yoctodelay": "^2.0.0"
|
||||||
},
|
},
|
||||||
"xo": {
|
"xo": {
|
||||||
|
|
@ -66,7 +67,8 @@
|
||||||
"unicorn/prefer-string-slice": "off",
|
"unicorn/prefer-string-slice": "off",
|
||||||
"@typescript-eslint/consistent-type-imports": "off",
|
"@typescript-eslint/consistent-type-imports": "off",
|
||||||
"@typescript-eslint/consistent-type-exports": "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": {
|
"c8": {
|
||||||
|
|
|
||||||
94
readme.md
94
readme.md
|
|
@ -12,71 +12,13 @@
|
||||||
[](https://codecov.io/gh/chalk/chalk)
|
[](https://codecov.io/gh/chalk/chalk)
|
||||||
[](https://www.npmjs.com/package/chalk?activeTab=dependents)
|
[](https://www.npmjs.com/package/chalk?activeTab=dependents)
|
||||||
[](https://www.npmjs.com/package/chalk)
|
[](https://www.npmjs.com/package/chalk)
|
||||||
[](https://repl.it/github/chalk/chalk)
|
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
<br>
|
## 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
|
||||||
<div align="center">
|
|
||||||
<p>
|
|
||||||
<p>
|
|
||||||
<sup>
|
|
||||||
Sindre Sorhus' open source work is supported by the community on <a href="https://github.com/sponsors/sindresorhus">GitHub Sponsors</a>
|
|
||||||
</sup>
|
|
||||||
</p>
|
|
||||||
<sup>Special thanks to:</sup>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
<a href="https://standardresume.co/tech">
|
|
||||||
<img src="https://sindresorhus.com/assets/thanks/standard-resume-logo.svg" width="160">
|
|
||||||
</a>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
<a href="https://retool.com/?utm_campaign=sindresorhus">
|
|
||||||
<img src="https://sindresorhus.com/assets/thanks/retool-logo.svg" width="230">
|
|
||||||
</a>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
<a href="https://doppler.com/?utm_campaign=github_repo&utm_medium=referral&utm_content=chalk&utm_source=github">
|
|
||||||
<div>
|
|
||||||
<img src="https://dashboard.doppler.com/imgs/logo-long.svg" width="240" alt="Doppler">
|
|
||||||
</div>
|
|
||||||
<b>All your environment variables, in one place</b>
|
|
||||||
<div>
|
|
||||||
<span>Stop struggling with scattered API keys, hacking together home-brewed tools,</span>
|
|
||||||
<br>
|
|
||||||
<span>and avoiding access controls. Keep your team and servers in sync with Doppler.</span>
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
<br>
|
|
||||||
<a href="https://strapi.io/?ref=sindresorhus">
|
|
||||||
<div>
|
|
||||||
<img src="https://sindresorhus.com/assets/thanks/strapi-logo-white-bg.png" width="220" alt="Strapi">
|
|
||||||
</div>
|
|
||||||
<b>Strapi is the leading open-source headless CMS.</b>
|
|
||||||
<div>
|
|
||||||
<sup>It’s 100% JavaScript, fully customizable, and developer-first.</sup>
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
<a href="https://www.stackaid.us/?utm_campaign=sindre">
|
|
||||||
<div>
|
|
||||||
<img src="https://sindresorhus.com/assets/thanks/stackaid-logo.png" width="230" alt="StackAid">
|
|
||||||
</div>
|
|
||||||
<b>Fund your open source dependencies</b>
|
|
||||||
</a>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
## Highlights
|
## Highlights
|
||||||
|
|
||||||
|
|
@ -89,7 +31,7 @@
|
||||||
- Doesn't extend `String.prototype`
|
- Doesn't extend `String.prototype`
|
||||||
- Clean and focused
|
- Clean and focused
|
||||||
- Actively maintained
|
- 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
|
## Install
|
||||||
|
|
||||||
|
|
@ -236,10 +178,10 @@ console.log(foregroundColorNames.includes('pink'));
|
||||||
- `italic` - Make the text italic. *(Not widely supported)*
|
- `italic` - Make the text italic. *(Not widely supported)*
|
||||||
- `underline` - Put a horizontal line below the text. *(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)*
|
- `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.
|
- `hidden` - Print the text but make it invisible.
|
||||||
- `strikethrough` - Puts a horizontal line through the center of the text. *(Not widely supported)*
|
- `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
|
### Colors
|
||||||
|
|
||||||
|
|
@ -281,7 +223,7 @@ console.log(foregroundColorNames.includes('pink'));
|
||||||
|
|
||||||
## 256 and Truecolor color support
|
## 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).
|
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).
|
||||||
|
|
||||||
|
|
@ -309,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`.
|
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
|
## Related
|
||||||
|
|
||||||
|
|
@ -331,6 +289,8 @@ If you're on Windows, do yourself a favor and use [Windows Terminal](https://git
|
||||||
- [chalk-pipe](https://github.com/LitoMore/chalk-pipe) - Create chalk style schemes with simpler style strings
|
- [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
|
- [terminal-link](https://github.com/sindresorhus/terminal-link) - Create clickable links in the terminal
|
||||||
|
|
||||||
|
*(Not accepting additional entries)*
|
||||||
|
|
||||||
## Maintainers
|
## Maintainers
|
||||||
|
|
||||||
- [Sindre Sorhus](https://github.com/sindresorhus)
|
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||||
|
|
|
||||||
7
source/index.d.ts
vendored
7
source/index.d.ts
vendored
|
|
@ -1,7 +1,12 @@
|
||||||
// TODO: Make it this when TS suports that.
|
// TODO: Make it this when TS suports that.
|
||||||
// import {ModifierName, ForegroundColor, BackgroundColor, ColorName} from '#ansi-styles';
|
// import {ModifierName, ForegroundColor, BackgroundColor, ColorName} from '#ansi-styles';
|
||||||
// import {ColorInfo, ColorSupportLevel} from '#supports-color';
|
// 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';
|
import {ColorInfo, ColorSupportLevel} from './vendor/supports-color/index.js';
|
||||||
|
|
||||||
export interface Options {
|
export interface Options {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,22 @@
|
||||||
import {expectType, expectAssignable, expectError, expectDeprecated} from 'tsd';
|
import {
|
||||||
|
expectType,
|
||||||
|
expectAssignable,
|
||||||
|
expectError,
|
||||||
|
expectDeprecated,
|
||||||
|
} from 'tsd';
|
||||||
import chalk, {
|
import chalk, {
|
||||||
Chalk, ChalkInstance, ColorInfo, ColorSupport, ColorSupportLevel, chalkStderr, supportsColor, supportsColorStderr,
|
Chalk,
|
||||||
ModifierName, ForegroundColorName, BackgroundColorName, ColorName,
|
ChalkInstance,
|
||||||
|
ColorInfo,
|
||||||
|
ColorSupport,
|
||||||
|
ColorSupportLevel,
|
||||||
|
chalkStderr,
|
||||||
|
supportsColor,
|
||||||
|
supportsColorStderr,
|
||||||
|
ModifierName,
|
||||||
|
ForegroundColorName,
|
||||||
|
BackgroundColorName,
|
||||||
|
ColorName,
|
||||||
Modifiers,
|
Modifiers,
|
||||||
} from './index.js';
|
} from './index.js';
|
||||||
|
|
||||||
|
|
|
||||||
31
source/vendor/supports-color/browser.js
vendored
31
source/vendor/supports-color/browser.js
vendored
|
|
@ -1,15 +1,30 @@
|
||||||
/* eslint-env browser */
|
/* eslint-env browser */
|
||||||
|
|
||||||
const isBlinkBasedBrowser = navigator.userAgentData
|
const level = (() => {
|
||||||
? navigator.userAgentData.brands.some(({brand}) => brand === 'Chromium')
|
if (!('navigator' in globalThis)) {
|
||||||
: /\b(Chrome|Chromium)\//.test(navigator.userAgent);
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
const colorSupport = isBlinkBasedBrowser ? {
|
if (globalThis.navigator.userAgentData) {
|
||||||
level: 1,
|
const brand = navigator.userAgentData.brands.find(({brand}) => brand === 'Chromium');
|
||||||
|
if (brand && brand.version > 93) {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
})();
|
||||||
|
|
||||||
|
const colorSupport = level !== 0 && {
|
||||||
|
level,
|
||||||
hasBasic: true,
|
hasBasic: true,
|
||||||
has256: false,
|
has256: level >= 2,
|
||||||
has16m: false,
|
has16m: level >= 3,
|
||||||
} : false;
|
};
|
||||||
|
|
||||||
const supportsColor = {
|
const supportsColor = {
|
||||||
stdout: colorSupport,
|
stdout: colorSupport,
|
||||||
|
|
|
||||||
12
source/vendor/supports-color/index.d.ts
vendored
12
source/vendor/supports-color/index.d.ts
vendored
|
|
@ -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.
|
Whether `process.argv` should be sniffed for `--color` and `--no-color` flags.
|
||||||
|
|
||||||
@default true
|
@default true
|
||||||
*/
|
*/
|
||||||
readonly sniffFlags?: boolean;
|
readonly sniffFlags?: boolean;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Levels:
|
Levels:
|
||||||
|
|
@ -21,7 +21,7 @@ export type ColorSupportLevel = 0 | 1 | 2 | 3;
|
||||||
/**
|
/**
|
||||||
Detect whether the terminal supports color.
|
Detect whether the terminal supports color.
|
||||||
*/
|
*/
|
||||||
export interface ColorSupport {
|
export type ColorSupport = {
|
||||||
/**
|
/**
|
||||||
The color level.
|
The color level.
|
||||||
*/
|
*/
|
||||||
|
|
@ -41,11 +41,11 @@ export interface ColorSupport {
|
||||||
Whether Truecolor 16 million colors are supported.
|
Whether Truecolor 16 million colors are supported.
|
||||||
*/
|
*/
|
||||||
has16m: boolean;
|
has16m: boolean;
|
||||||
}
|
};
|
||||||
|
|
||||||
export type ColorInfo = ColorSupport | false;
|
export type ColorInfo = ColorSupport | false;
|
||||||
|
|
||||||
export function createSupportsColor(stream: WriteStream, options?: Options): ColorInfo;
|
export function createSupportsColor(stream?: WriteStream, options?: Options): ColorInfo;
|
||||||
|
|
||||||
declare const supportsColor: {
|
declare const supportsColor: {
|
||||||
stdout: ColorInfo;
|
stdout: ColorInfo;
|
||||||
|
|
|
||||||
37
source/vendor/supports-color/index.js
vendored
37
source/vendor/supports-color/index.js
vendored
|
|
@ -3,7 +3,8 @@ import os from 'node:os';
|
||||||
import tty from 'node:tty';
|
import tty from 'node:tty';
|
||||||
|
|
||||||
// From: https://github.com/sindresorhus/has-flag/blob/main/index.js
|
// From: https://github.com/sindresorhus/has-flag/blob/main/index.js
|
||||||
function hasFlag(flag, argv = process.argv) {
|
/// 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 prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
|
||||||
const position = argv.indexOf(prefix + flag);
|
const position = argv.indexOf(prefix + flag);
|
||||||
const terminatorPosition = argv.indexOf('--');
|
const terminatorPosition = argv.indexOf('--');
|
||||||
|
|
@ -80,6 +81,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) {
|
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -105,7 +112,11 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('CI' in env) {
|
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', 'GITEA_ACTIONS', 'CIRCLECI'].some(key => key in env)) {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (['TRAVIS', 'APPVEYOR', 'GITLAB_CI', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -116,12 +127,19 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {
|
||||||
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for Azure DevOps pipelines
|
if (env.COLORTERM === 'truecolor') {
|
||||||
if ('TF_BUILD' in env && 'AGENT_NAME' in env) {
|
return 3;
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (env.COLORTERM === 'truecolor') {
|
if (env.TERM === 'xterm-kitty') {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (env.TERM === 'xterm-ghostty') {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (env.TERM === 'wezterm') {
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -129,10 +147,13 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {
|
||||||
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
||||||
|
|
||||||
switch (env.TERM_PROGRAM) {
|
switch (env.TERM_PROGRAM) {
|
||||||
case 'iTerm.app':
|
case 'iTerm.app': {
|
||||||
return version >= 3 ? 3 : 2;
|
return version >= 3 ? 3 : 2;
|
||||||
case 'Apple_Terminal':
|
}
|
||||||
|
|
||||||
|
case 'Apple_Terminal': {
|
||||||
return 2;
|
return 2;
|
||||||
|
}
|
||||||
// No default
|
// No default
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue