@@ -87,10 +87,11 @@ export function statsToString(json: any, statsConfig: any) {
87
87
}
88
88
89
89
// TODO(#16193): Don't emit this warning in the first place rather than just suppressing it.
90
- const ERRONEOUS_WARNINGS = [
90
+ const ERRONEOUS_WARNINGS_FILTER = ( warning : string ) => ! [
91
91
/ m u l t i p l e a s s e t s e m i t d i f f e r e n t c o n t e n t .* 3 r d p a r t y l i c e n s e s \. t x t / i,
92
- ] ;
93
- export function statsWarningsToString ( json : any , statsConfig : any ) {
92
+ ] . some ( msg => msg . test ( warning ) ) ;
93
+
94
+ export function statsWarningsToString ( json : any , statsConfig : any ) : string {
94
95
const colors = statsConfig . colors ;
95
96
const rs = ( x : string ) => colors ? reset ( x ) : x ;
96
97
const y = ( x : string ) => colors ? bold ( yellow ( x ) ) : x ;
@@ -104,12 +105,12 @@ export function statsWarningsToString(json: any, statsConfig: any) {
104
105
105
106
return rs ( '\n' + warnings
106
107
. map ( ( warning : any ) => `${ warning } ` )
107
- . filter ( ( warning : string ) => ! ERRONEOUS_WARNINGS . some ( ( erroneous ) => erroneous . test ( warning ) ) )
108
+ . filter ( ERRONEOUS_WARNINGS_FILTER )
108
109
. map ( ( warning : string ) => y ( `WARNING in ${ warning } ` ) )
109
110
. join ( '\n\n' ) ) ;
110
111
}
111
112
112
- export function statsErrorsToString ( json : any , statsConfig : any ) {
113
+ export function statsErrorsToString ( json : any , statsConfig : any ) : string {
113
114
const colors = statsConfig . colors ;
114
115
const rs = ( x : string ) => colors ? reset ( x ) : x ;
115
116
const r = ( x : string ) => colors ? bold ( red ( x ) ) : x ;
@@ -120,16 +121,18 @@ export function statsErrorsToString(json: any, statsConfig: any) {
120
121
. reduce ( ( a : string [ ] , b : string [ ] ) => [ ...a , ...b ] , [ ] )
121
122
) ;
122
123
}
124
+
123
125
return rs ( '\n' + errors
124
126
. map ( ( error : any ) => r ( `ERROR in ${ error } ` ) )
125
127
. join ( '\n\n' )
126
128
) ;
127
129
}
128
130
129
131
export function statsHasErrors ( json : any ) : boolean {
130
- return json . errors . length > 0 || ! ! json . children ?. some ( ( c : any ) => c . errors . length ) ;
132
+ return json . errors . length || ! ! json . children ?. some ( ( c : any ) => c . errors . length ) ;
131
133
}
132
134
133
135
export function statsHasWarnings ( json : any ) : boolean {
134
- return json . warnings . length > 0 || ! ! json . children ?. some ( ( c : any ) => c . warnings . length ) ;
136
+ return json . warnings . filter ( ERRONEOUS_WARNINGS_FILTER ) . length ||
137
+ ! ! json . children ?. some ( ( c : any ) => c . warnings . filter ( ERRONEOUS_WARNINGS_FILTER ) . length ) ;
135
138
}
0 commit comments