1
- import { bold , green , reset , white , yellow } from 'chalk' ;
1
+ import { bold , green , red , reset , white , yellow } from 'chalk' ;
2
2
import { stripIndents } from 'common-tags' ;
3
3
4
4
@@ -16,12 +16,12 @@ function _formatSize(size: number): string {
16
16
17
17
export function statsToString ( json : any , statsConfig : any ) {
18
18
const colors = statsConfig . colors ;
19
- const r = ( x : string ) => colors ? reset ( x ) : x ;
19
+ const rs = ( x : string ) => colors ? reset ( x ) : x ;
20
20
const w = ( x : string ) => colors ? bold ( white ( x ) ) : x ;
21
21
const g = ( x : string ) => colors ? bold ( green ( x ) ) : x ;
22
22
const y = ( x : string ) => colors ? bold ( yellow ( x ) ) : x ;
23
23
24
- return r ( stripIndents `
24
+ return rs ( stripIndents `
25
25
Date: ${ w ( new Date ( ) . toISOString ( ) ) }
26
26
Hash: ${ w ( json . hash ) }
27
27
Time: ${ w ( '' + json . time ) } ms
@@ -38,8 +38,21 @@ export function statsToString(json: any, statsConfig: any) {
38
38
39
39
return `chunk {${ y ( chunk . id ) } } ${ g ( files ) } ${ names } ${ size } ${ parents } ${ initial } ${ flags } ` ;
40
40
} ) . 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' ) }
44
41
` ) ;
45
42
}
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