supports-color 9.2.2 → 9.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser.js +19 -8
- package/index.d.ts +1 -1
- package/index.js +15 -6
- package/package.json +1 -1
package/browser.js
CHANGED
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
/* eslint-env browser */
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
const level = (() => {
|
|
4
|
+
if (navigator.userAgentData) {
|
|
5
|
+
const brand = navigator.userAgentData.brands.find(({brand}) => brand === 'Chromium');
|
|
6
|
+
if (brand?.version > 93) {
|
|
7
|
+
return 3;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
6
10
|
|
|
7
|
-
|
|
8
|
-
|
|
11
|
+
if (/\b(Chrome|Chromium)\//.test(navigator.userAgent)) {
|
|
12
|
+
return 1;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return 0;
|
|
16
|
+
})();
|
|
17
|
+
|
|
18
|
+
const colorSupport = level !== 0 && {
|
|
19
|
+
level,
|
|
9
20
|
hasBasic: true,
|
|
10
|
-
has256:
|
|
11
|
-
has16m:
|
|
12
|
-
}
|
|
21
|
+
has256: level >= 2,
|
|
22
|
+
has16m: level >= 3,
|
|
23
|
+
};
|
|
13
24
|
|
|
14
25
|
const supportsColor = {
|
|
15
26
|
stdout: colorSupport,
|
package/index.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export interface ColorSupport {
|
|
|
45
45
|
|
|
46
46
|
export type ColorInfo = ColorSupport | false;
|
|
47
47
|
|
|
48
|
-
export function createSupportsColor(stream
|
|
48
|
+
export function createSupportsColor(stream?: WriteStream, options?: Options): ColorInfo;
|
|
49
49
|
|
|
50
50
|
declare const supportsColor: {
|
|
51
51
|
stdout: ColorInfo;
|
package/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import os from 'node:os';
|
|
|
3
3
|
import tty from 'node:tty';
|
|
4
4
|
|
|
5
5
|
// From: https://github.com/sindresorhus/has-flag/blob/main/index.js
|
|
6
|
-
function hasFlag(flag, argv = process.argv) {
|
|
6
|
+
function hasFlag(flag, argv = globalThis.Deno?.args ?? process.argv) {
|
|
7
7
|
const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
|
|
8
8
|
const position = argv.indexOf(prefix + flag);
|
|
9
9
|
const terminatorPosition = argv.indexOf('--');
|
|
@@ -80,6 +80,12 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
// Check for Azure DevOps pipelines.
|
|
84
|
+
// Has to be above the `!streamIsTTY` check.
|
|
85
|
+
if ('TF_BUILD' in env && 'AGENT_NAME' in env) {
|
|
86
|
+
return 1;
|
|
87
|
+
}
|
|
88
|
+
|
|
83
89
|
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
|
84
90
|
return 0;
|
|
85
91
|
}
|
|
@@ -105,7 +111,11 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {
|
|
|
105
111
|
}
|
|
106
112
|
|
|
107
113
|
if ('CI' in env) {
|
|
108
|
-
if (
|
|
114
|
+
if ('GITHUB_ACTIONS' in env) {
|
|
115
|
+
return 3;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
|
|
109
119
|
return 1;
|
|
110
120
|
}
|
|
111
121
|
|
|
@@ -116,12 +126,11 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {
|
|
|
116
126
|
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
117
127
|
}
|
|
118
128
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
return 1;
|
|
129
|
+
if (env.COLORTERM === 'truecolor') {
|
|
130
|
+
return 3;
|
|
122
131
|
}
|
|
123
132
|
|
|
124
|
-
if (env.
|
|
133
|
+
if (env.TERM === 'xterm-kitty') {
|
|
125
134
|
return 3;
|
|
126
135
|
}
|
|
127
136
|
|