File tree Expand file tree Collapse file tree 2 files changed +28
-11
lines changed
source/vendor/supports-color Expand file tree Collapse file tree 2 files changed +28
-11
lines changed Original file line number Diff line number Diff line change 11/* eslint-env browser */
2+ /* eslint-disable n/no-unsupported-features/node-builtins */
23
34const 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 ( C h r o m e | C h r o m i u m ) \/ / . test ( navigator . userAgent ) ) {
16+ if ( / \b ( C h r o m e | C h r o m i u m ) \/ / . test ( globalThis . navigator . userAgent ) ) {
1217 return 1 ;
1318 }
1419
Original file line number Diff line number Diff line change 3131}
3232
3333function 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
4759function translateLevel ( level ) {
You can’t perform that action at this time.
0 commit comments