supports-color 9.2.3 → 9.3.1
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 +21 -8
- package/package.json +2 -2
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
package/index.js
CHANGED
|
@@ -3,7 +3,8 @@ 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
|
+
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process.argv) {
|
|
7
8
|
const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
|
|
8
9
|
const position = argv.indexOf(prefix + flag);
|
|
9
10
|
const terminatorPosition = argv.indexOf('--');
|
|
@@ -80,6 +81,12 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {
|
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
|
|
84
|
+
// Check for Azure DevOps pipelines.
|
|
85
|
+
// Has to be above the `!streamIsTTY` check.
|
|
86
|
+
if ('TF_BUILD' in env && 'AGENT_NAME' in env) {
|
|
87
|
+
return 1;
|
|
88
|
+
}
|
|
89
|
+
|
|
83
90
|
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
|
84
91
|
return 0;
|
|
85
92
|
}
|
|
@@ -105,7 +112,11 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {
|
|
|
105
112
|
}
|
|
106
113
|
|
|
107
114
|
if ('CI' in env) {
|
|
108
|
-
if (
|
|
115
|
+
if ('GITHUB_ACTIONS' in env) {
|
|
116
|
+
return 3;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
|
|
109
120
|
return 1;
|
|
110
121
|
}
|
|
111
122
|
|
|
@@ -116,12 +127,11 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {
|
|
|
116
127
|
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
117
128
|
}
|
|
118
129
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
return 1;
|
|
130
|
+
if (env.COLORTERM === 'truecolor') {
|
|
131
|
+
return 3;
|
|
122
132
|
}
|
|
123
133
|
|
|
124
|
-
if (env.
|
|
134
|
+
if (env.TERM === 'xterm-kitty') {
|
|
125
135
|
return 3;
|
|
126
136
|
}
|
|
127
137
|
|
|
@@ -129,10 +139,13 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {
|
|
|
129
139
|
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
|
130
140
|
|
|
131
141
|
switch (env.TERM_PROGRAM) {
|
|
132
|
-
case 'iTerm.app':
|
|
142
|
+
case 'iTerm.app': {
|
|
133
143
|
return version >= 3 ? 3 : 2;
|
|
134
|
-
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
case 'Apple_Terminal': {
|
|
135
147
|
return 2;
|
|
148
|
+
}
|
|
136
149
|
// No default
|
|
137
150
|
}
|
|
138
151
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "supports-color",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.3.1",
|
|
4
4
|
"description": "Detect whether a terminal supports color",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "chalk/supports-color",
|
|
@@ -56,6 +56,6 @@
|
|
|
56
56
|
"import-fresh": "^3.3.0",
|
|
57
57
|
"tsd": "^0.18.0",
|
|
58
58
|
"typescript": "^4.4.3",
|
|
59
|
-
"xo": "^0.
|
|
59
|
+
"xo": "^0.49.0"
|
|
60
60
|
}
|
|
61
61
|
}
|