File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
src/Symfony/Component/Console Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change 13
13
14
14
use Symfony \Component \Console \Exception \InvalidArgumentException ;
15
15
use Symfony \Component \Console \Formatter \OutputFormatterInterface ;
16
+ use function preg_match ;
16
17
17
18
/**
18
19
* StreamOutput writes the output to a given stream.
@@ -106,10 +107,22 @@ protected function hasColorSupport()
106
107
return true ;
107
108
}
108
109
109
- return 'Hyper ' === getenv ('TERM_PROGRAM ' )
110
+ if ('Hyper ' === getenv ('TERM_PROGRAM ' )
111
+ || false !== getenv ('COLORTERM ' )
110
112
|| false !== getenv ('ANSICON ' )
111
113
|| 'ON ' === getenv ('ConEmuANSI ' )
112
- || str_starts_with ((string ) getenv ('TERM ' ), 'xterm ' );
114
+ ) {
115
+ return true ;
116
+ }
117
+
118
+ $ term = (string ) getenv ('TERM ' );
119
+
120
+ if ('dumb ' === $ term ) {
121
+ return false ;
122
+ }
123
+
124
+ // See https://github.com/chalk/supports-color/blob/d4f413efaf8da045c5ab440ed418ef02dbb28bf1/index.js#L157
125
+ return 1 === @preg_match ('/^((xterm|screen|putty|rxvt|linux).*)|(.*-256color(-bce)?)$/ ' , $ term );
113
126
}
114
127
115
128
/**
Original file line number Diff line number Diff line change 17
17
],
18
18
"require" : {
19
19
"php" : " >=7.2.5" ,
20
+ "ext-pcre" : " *" ,
20
21
"symfony/deprecation-contracts" : " ^2.1|^3" ,
21
22
"symfony/polyfill-mbstring" : " ~1.0" ,
22
23
"symfony/polyfill-php73" : " ^1.9" ,
You can’t perform that action at this time.
0 commit comments