Skip to content

Commit a204e5f

Browse files
committed
Update supports-color to v10.0.0
1 parent fc809b6 commit a204e5f

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

source/vendor/supports-color/browser.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
/* eslint-env browser */
2+
/* eslint-disable n/no-unsupported-features/node-builtins */
23

34
const level = (() => {
4-
if (navigator.userAgentData) {
5+
if (!('navigator' in globalThis)) {
6+
return 0;
7+
}
8+
9+
if (globalThis.navigator.userAgentData) {
510
const brand = navigator.userAgentData.brands.find(({brand}) => brand === 'Chromium');
6-
if (brand && brand.version > 93) {
11+
if (brand?.version > 93) {
712
return 3;
813
}
914
}
1015

11-
if (/\b(Chrome|Chromium)\//.test(navigator.userAgent)) {
16+
if (/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)) {
1217
return 1;
1318
}
1419

source/vendor/supports-color/index.js

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,29 @@ if (
3131
}
3232

3333
function envForceColor() {
34-
if ('FORCE_COLOR' in env) {
35-
if (env.FORCE_COLOR === 'true') {
36-
return 1;
37-
}
34+
if (!('FORCE_COLOR' in env)) {
35+
return;
36+
}
3837

39-
if (env.FORCE_COLOR === 'false') {
40-
return 0;
41-
}
38+
if (env.FORCE_COLOR === 'true') {
39+
return 1;
40+
}
41+
42+
if (env.FORCE_COLOR === 'false') {
43+
return 0;
44+
}
4245

43-
return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
46+
if (env.FORCE_COLOR.length === 0) {
47+
return 1;
4448
}
49+
50+
const level = Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
51+
52+
if (![0, 1, 2, 3].includes(level)) {
53+
return;
54+
}
55+
56+
return level;
4557
}
4658

4759
function translateLevel(level) {

0 commit comments

Comments
 (0)