Skip to content

Commit f038793

Browse files
committed
Fix navigator not defined ReferenceError
chalk/supports-color@c214314
1 parent fc809b6 commit f038793

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

source/vendor/supports-color/browser.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
/* eslint-env browser */
22

33
const level = (() => {
4-
if (navigator.userAgentData) {
4+
if (!('navigator' in globalThis)) {
5+
return 0;
6+
}
7+
8+
if (globalThis.navigator.userAgentData) {
59
const brand = navigator.userAgentData.brands.find(({brand}) => brand === 'Chromium');
610
if (brand && brand.version > 93) {
711
return 3;
812
}
913
}
1014

11-
if (/\b(Chrome|Chromium)\//.test(navigator.userAgent)) {
15+
if (/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)) {
1216
return 1;
1317
}
1418

0 commit comments

Comments
 (0)