@@ -110,8 +110,8 @@ function clean(args) {
110
110
delegate ( [ "clean" , ...args ] ) ;
111
111
}
112
112
113
- const isTtyError = process . stderr . isTTY ;
114
- const isTtyStd = process . stdout . isTTY ;
113
+ const shouldColorizeError = process . stderr . isTTY || process . env . FORCE_COLOR == "1" ;
114
+ const shouldColorize = process . stdout . isTTY || process . env . FORCE_COLOR == "1" ;
115
115
116
116
/**
117
117
* @type {[number,number] }
@@ -133,7 +133,7 @@ function logFinishCompiling(code) {
133
133
if ( code ) {
134
134
log = log + " (exit: " + code + ")" ;
135
135
}
136
- if ( isTtyStd ) {
136
+ if ( shouldColorize ) {
137
137
log = "\x1b[36m" + log + "\x1b[0m" ;
138
138
}
139
139
if ( code ) {
@@ -146,7 +146,7 @@ function logFinishCompiling(code) {
146
146
function logStartCompiling ( ) {
147
147
updateStartTime ( ) ;
148
148
let log = `>>>> Start compiling` ;
149
- if ( isTtyStd ) {
149
+ if ( shouldColorize ) {
150
150
log = "\x1b[36m" + log + "\x1b[0m" ;
151
151
}
152
152
console . log ( log ) ;
@@ -265,7 +265,7 @@ function watch(args) {
265
265
. on ( "error" , function ( err ) {
266
266
// @ts -ignore
267
267
if ( err !== undefined && err . code === "EADDRINUSE" ) {
268
- var error = isTtyStd ? `\x1b[1;31mERROR:\x1b[0m` : `ERROR:` ;
268
+ var error = shouldColorize ? `\x1b[1;31mERROR:\x1b[0m` : `ERROR:` ;
269
269
console . error ( `${ error } The websocket port number ${ webSocketPort } is in use.
270
270
Please pick a different one using the \`-ws [host:]port\` flag from bsb.` ) ;
271
271
} else {
@@ -358,7 +358,7 @@ Please pick a different one using the \`-ws [host:]port\` flag from bsb.`);
358
358
* @param highlight {string}
359
359
*/
360
360
function outputError ( error , highlight ) {
361
- if ( isTtyError && highlight ) {
361
+ if ( shouldColorizeError && highlight ) {
362
362
process . stderr . write (
363
363
error . replace ( highlight , "\x1b[1;31m" + highlight + "\x1b[0m" ) ,
364
364
) ;
0 commit comments