import * as fs from "fs" ; import * as path from "path" ; import * as mkdirp from "mkdirp" ; import ansiСolors = require ( "ansi-colors" ) ; export class SmokeTestLogger { public static log ( ... str ) { console . log ( ... str ) ; } public static info ( ... str ) { console . log ( SmokeTestLogger . colorize ( str . join ( " " ) , ansiСolors . styles . blue ) ) ; } public static warn ( ... str ) { console . log ( SmokeTestLogger . colorize ( str . join ( " " ) , ansiСolors . styles . yellow ) ) ; } public static success ( ... str ) { console . log ( SmokeTestLogger . colorize ( str . join ( " " ) , ansiСolors . styles . green ) ) ; } public static projectInstallLog ( ... str ) { console . log ( SmokeTestLogger . colorize ( str . join ( " " ) , ansiСolors . styles . cyanBright ) ) ; } public static projectPatchingLog ( ... str ) { console . log ( SmokeTestLogger . colorize ( str . join ( " " ) , ansiСolors . styles . magentaBright ) ) ; } public static error ( err ) { console . error ( SmokeTestLogger . colorize ( err . toString ( ) , ansiСolors . styles . red ) ) ; } public static saveLogsInFile ( str , filePath ) { if ( ! fs . existsSync ( filePath ) ) { mkdirp . sync ( path . dirname ( filePath ) ) ; } fs . appendFileSync ( filePath , str ) ; } private static colorize ( str , color ) { return str . split ( "\n" ) . map ( line => SmokeTestLogger . colorizeLine ( line , color ) ) . join ( "\n" ) ; } private static colorizeLine ( str , color ) { return `${ color . open }${ str }${ ansiСolors . styles . reset . open }` ; } }