@@ -110,8 +110,8 @@ function clean(args) {
110110 delegate ( [ "clean" , ...args ] ) ;
111111}
112112
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" ;
115115
116116/**
117117 * @type {[number,number] }
@@ -133,7 +133,7 @@ function logFinishCompiling(code) {
133133 if ( code ) {
134134 log = log + " (exit: " + code + ")" ;
135135 }
136- if ( isTtyStd ) {
136+ if ( shouldColorize ) {
137137 log = "\x1b[36m" + log + "\x1b[0m" ;
138138 }
139139 if ( code ) {
@@ -146,7 +146,7 @@ function logFinishCompiling(code) {
146146function logStartCompiling ( ) {
147147 updateStartTime ( ) ;
148148 let log = `>>>> Start compiling` ;
149- if ( isTtyStd ) {
149+ if ( shouldColorize ) {
150150 log = "\x1b[36m" + log + "\x1b[0m" ;
151151 }
152152 console . log ( log ) ;
@@ -265,7 +265,7 @@ function watch(args) {
265265 . on ( "error" , function ( err ) {
266266 // @ts -ignore
267267 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:` ;
269269 console . error ( `${ error } The websocket port number ${ webSocketPort } is in use.
270270Please pick a different one using the \`-ws [host:]port\` flag from bsb.` ) ;
271271 } else {
@@ -358,7 +358,7 @@ Please pick a different one using the \`-ws [host:]port\` flag from bsb.`);
358358 * @param highlight {string}
359359 */
360360 function outputError ( error , highlight ) {
361- if ( isTtyError && highlight ) {
361+ if ( shouldColorizeError && highlight ) {
362362 process . stderr . write (
363363 error . replace ( highlight , "\x1b[1;31m" + highlight + "\x1b[0m" ) ,
364364 ) ;
0 commit comments