1- import { bold , green , reset , white , yellow } from 'chalk' ;
1+ import { bold , green , red , reset , white , yellow } from 'chalk' ;
22import { stripIndents } from 'common-tags' ;
33
44
@@ -16,12 +16,12 @@ function _formatSize(size: number): string {
1616
1717export function statsToString ( json : any , statsConfig : any ) {
1818 const colors = statsConfig . colors ;
19- const r = ( x : string ) => colors ? reset ( x ) : x ;
19+ const rs = ( x : string ) => colors ? reset ( x ) : x ;
2020 const w = ( x : string ) => colors ? bold ( white ( x ) ) : x ;
2121 const g = ( x : string ) => colors ? bold ( green ( x ) ) : x ;
2222 const y = ( x : string ) => colors ? bold ( yellow ( x ) ) : x ;
2323
24- return r ( stripIndents `
24+ return rs ( stripIndents `
2525 Date: ${ w ( new Date ( ) . toISOString ( ) ) }
2626 Hash: ${ w ( json . hash ) }
2727 Time: ${ w ( '' + json . time ) } ms
@@ -38,8 +38,21 @@ export function statsToString(json: any, statsConfig: any) {
3838
3939 return `chunk {${ y ( chunk . id ) } } ${ g ( files ) } ${ names } ${ size } ${ parents } ${ initial } ${ flags } ` ;
4040 } ) . join ( '\n' ) }
41-
42- ${ json . warnings . map ( ( warning : any ) => y ( `WARNING in ${ warning } ` ) ) . join ( '\n\n' ) }
43- ${ json . errors . map ( ( error : any ) => r ( `ERROR in ${ error } ` ) ) . join ( '\n' ) }
4441 ` ) ;
4542}
43+
44+ export function statsWarningsToString ( json : any , statsConfig : any ) {
45+ const colors = statsConfig . colors ;
46+ const rs = ( x : string ) => colors ? reset ( x ) : x ;
47+ const y = ( x : string ) => colors ? bold ( yellow ( x ) ) : x ;
48+
49+ return rs ( '\n' + json . warnings . map ( ( warning : any ) => y ( `WARNING in ${ warning } ` ) ) . join ( '\n\n' ) ) ;
50+ }
51+
52+ export function statsErrorsToString ( json : any , statsConfig : any ) {
53+ const colors = statsConfig . colors ;
54+ const rs = ( x : string ) => colors ? reset ( x ) : x ;
55+ const r = ( x : string ) => colors ? bold ( red ( x ) ) : x ;
56+
57+ return rs ( '\n' + json . errors . map ( ( error : any ) => r ( `ERROR in ${ error } ` ) ) . join ( '\n' ) ) ;
58+ }
0 commit comments