import chalk from "chalk" ; import isCI from "is-ci" ; const prefix = "[esbuild-scripts] " ; const DEBUG = Boolean ( process . env . REACT_LOGGER_DEBUG || process . argv . includes ( "--verbose" ) ) ; const SILENT = Boolean ( process . env . REACT_LOGGER_MUTE ) ; const isInteractive = process . stdout . isTTY ; function printStdErr ( x ) { if ( SILENT ) { return ; } x . split ( "\n" ) . forEach ( ( l ) => { process . stderr . write ( chalk . dim ( prefix ) + l + "\n" ) ; } ) ; } function printStdOut ( x ) { if ( SILENT ) { return ; } x . split ( "\n" ) . forEach ( ( l ) => { process . stdout . write ( chalk . dim ( prefix ) + l + "\n" ) ; } ) ; } export function log ( ... x ) { printStdOut ( x . join ( " " ) ) ; } export function warn ( ... x ) { printStdErr ( chalk . yellow ( x . join ( " " ) ) ) ; } export function error ( ... x ) { printStdErr ( chalk . red ( x . join ( " " ) ) ) ; } export function clear ( ) { if ( ! isCI && isInteractive && ! DEBUG ) { process . stdout . write ( process . platform === "win32" ? "\x1B[2J\x1B[0f" : "\x1B[2J\x1B[3J\x1B[H" ) ; } } export function debug ( ... x ) { if ( DEBUG ) { log ( "[debug]" , ... x ) ; } }