supports-color 9.2.3 → 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.
Files changed (3) hide show
  1. package/browser.js +19 -8
  2. package/index.js +15 -6
  3. package/package.json +1 -1
package/browser.js CHANGED
@@ -1,15 +1,26 @@
1
1
  /* eslint-env browser */
2
2
 
3
- const isBlinkBasedBrowser = navigator.userAgentData
4
- ? navigator.userAgentData.brands.some(({brand}) => brand === 'Chromium')
5
- : /\b(Chrome|Chromium)\//.test(navigator.userAgent);
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
- const colorSupport = isBlinkBasedBrowser ? {
8
- level: 1,
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: false,
11
- has16m: false,
12
- } : false;
21
+ has256: level >= 2,
22
+ has16m: level >= 3,
23
+ };
13
24
 
14
25
  const supportsColor = {
15
26
  stdout: colorSupport,
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 (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
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
- // Check for Azure DevOps pipelines
120
- if ('TF_BUILD' in env && 'AGENT_NAME' in env) {
121
- return 1;
129
+ if (env.COLORTERM === 'truecolor') {
130
+ return 3;
122
131
  }
123
132
 
124
- if (env.COLORTERM === 'truecolor') {
133
+ if (env.TERM === 'xterm-kitty') {
125
134
  return 3;
126
135
  }
127
136
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "supports-color",
3
- "version": "9.2.3",
3
+ "version": "9.3.0",
4
4
  "description": "Detect whether a terminal supports color",
5
5
  "license": "MIT",
6
6
  "repository": "chalk/supports-color",