@@ -87,10 +87,11 @@ export function statsToString(json: any, statsConfig: any) {
8787}
8888
8989// 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 ) => ! [
9191 / 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 {
9495 const colors = statsConfig . colors ;
9596 const rs = ( x : string ) => colors ? reset ( x ) : x ;
9697 const y = ( x : string ) => colors ? bold ( yellow ( x ) ) : x ;
@@ -104,12 +105,12 @@ export function statsWarningsToString(json: any, statsConfig: any) {
104105
105106 return rs ( '\n' + warnings
106107 . map ( ( warning : any ) => `${ warning } ` )
107- . filter ( ( warning : string ) => ! ERRONEOUS_WARNINGS . some ( ( erroneous ) => erroneous . test ( warning ) ) )
108+ . filter ( ERRONEOUS_WARNINGS_FILTER )
108109 . map ( ( warning : string ) => y ( `WARNING in ${ warning } ` ) )
109110 . join ( '\n\n' ) ) ;
110111}
111112
112- export function statsErrorsToString ( json : any , statsConfig : any ) {
113+ export function statsErrorsToString ( json : any , statsConfig : any ) : string {
113114 const colors = statsConfig . colors ;
114115 const rs = ( x : string ) => colors ? reset ( x ) : x ;
115116 const r = ( x : string ) => colors ? bold ( red ( x ) ) : x ;
@@ -120,16 +121,18 @@ export function statsErrorsToString(json: any, statsConfig: any) {
120121 . reduce ( ( a : string [ ] , b : string [ ] ) => [ ...a , ...b ] , [ ] )
121122 ) ;
122123 }
124+
123125 return rs ( '\n' + errors
124126 . map ( ( error : any ) => r ( `ERROR in ${ error } ` ) )
125127 . join ( '\n\n' )
126128 ) ;
127129}
128130
129131export 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 ) ;
131133}
132134
133135export 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 ) ;
135138}
0 commit comments