Comparing version 5.1.2 to 5.2.0
{ | ||
"name": "chalk", | ||
"version": "5.1.2", | ||
"version": "5.2.0", | ||
"description": "Terminal string styling done right", | ||
@@ -61,3 +61,3 @@ "license": "MIT", | ||
"tsd": "^0.19.0", | ||
"xo": "^0.52.4", | ||
"xo": "^0.53.0", | ||
"yoctodelay": "^2.0.0" | ||
@@ -64,0 +64,0 @@ }, |
@@ -15,3 +15,3 @@ <h1 align="center"> | ||
[![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) | ||
@@ -44,14 +44,2 @@ ![](media/screenshot.png) | ||
<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"> | ||
@@ -286,3 +274,3 @@ <div> | ||
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. | ||
@@ -289,0 +277,0 @@ 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). |
/* 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, | ||
}; | ||
@@ -14,0 +25,0 @@ const supportsColor = { |
@@ -1,4 +0,4 @@ | ||
import {WriteStream} from 'node:tty'; | ||
import type {WriteStream} from 'node:tty'; | ||
export interface Options { | ||
export type Options = { | ||
/** | ||
@@ -10,3 +10,3 @@ Whether `process.argv` should be sniffed for `--color` and `--no-color` flags. | ||
readonly sniffFlags?: boolean; | ||
} | ||
}; | ||
@@ -25,3 +25,3 @@ /** | ||
*/ | ||
export interface ColorSupport { | ||
export type ColorSupport = { | ||
/** | ||
@@ -46,7 +46,7 @@ The color level. | ||
has16m: boolean; | ||
} | ||
}; | ||
export type ColorInfo = ColorSupport | false; | ||
export function createSupportsColor(stream: WriteStream, options?: Options): ColorInfo; | ||
export function createSupportsColor(stream?: WriteStream, options?: Options): ColorInfo; | ||
@@ -53,0 +53,0 @@ declare const supportsColor: { |
@@ -6,3 +6,3 @@ import process from 'node:process'; | ||
// 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 ? '-' : '--'); | ||
@@ -84,2 +84,8 @@ const position = argv.indexOf(prefix + flag); | ||
// 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) { | ||
@@ -110,3 +116,7 @@ return 0; | ||
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; | ||
@@ -122,8 +132,7 @@ } | ||
// 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; | ||
@@ -136,6 +145,9 @@ } | ||
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 | ||
@@ -142,0 +154,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1046
43568
326