@@ -70,18 +70,40 @@ export function LogReport({ silent }: Context, report: Map<ItemConfig['path'], C
70
70
if ( ! silent && [ ...report . keys ( ) ] . length > 0 ) {
71
71
console . log ( bold ( '\nFilesize Report' ) ) ;
72
72
for ( const [ originalPath , values ] of report ) {
73
- console . log ( grey ( `\npath: ${ originalPath } ` ) ) ;
74
- for ( const [ compression , compressionResults ] of values ) {
75
- const [ size , maxSize ] = compressionResults ;
76
- const compressedPath = originalPath + grey ( compressedExtension ( compression ) ) ;
77
- if ( size === null || maxSize === null ) {
78
- continue ;
79
- } else if ( size < maxSize ) {
80
- success ++ ;
81
- console . log ( ` ✔️ ${ compressedPath } ${ prettyBytes ( size ) } ${ green ( '<' ) } ${ prettyBytes ( maxSize ) } ` ) ;
82
- } else {
83
- failure ++ ;
84
- console . log ( ` ❌ ${ compressedPath } ${ prettyBytes ( size ) } ${ red ( '>' ) } ${ prettyBytes ( maxSize ) } ` ) ;
73
+ const multipleOutputs = Array . from ( values . values ( ) ) . filter ( ( [ before ] ) => before !== null ) . length > 1 ;
74
+ if ( multipleOutputs ) {
75
+ console . log ( grey ( `\npath: ${ originalPath } ` ) ) ;
76
+ for ( const [ compression , compressionResults ] of values ) {
77
+ const [ size , maxSize ] = compressionResults ;
78
+ const compressedPath = originalPath + grey ( compressedExtension ( compression ) ) ;
79
+ if ( size === null || maxSize === null ) {
80
+ continue ;
81
+ } else if ( size < maxSize ) {
82
+ success ++ ;
83
+ console . log ( ` ✔️ ${ compressedPath } ${ prettyBytes ( size ) } ${ green ( '<' ) } ${ prettyBytes ( maxSize ) } ` ) ;
84
+ } else {
85
+ failure ++ ;
86
+ console . log ( ` ❌ ${ compressedPath } ${ prettyBytes ( size ) } ${ red ( '>' ) } ${ prettyBytes ( maxSize ) } ` ) ;
87
+ }
88
+ }
89
+ } else {
90
+ const maximumPath =
91
+ Math . max . apply (
92
+ null ,
93
+ Array . from ( report . keys ( ) ) . map ( item => item . length ) ,
94
+ ) + 1 ;
95
+ for ( const [ compression , compressionResults ] of values ) {
96
+ const [ size , maxSize ] = compressionResults ;
97
+ const compressedPath = originalPath + grey ( compressedExtension ( compression ) ) + new Array ( maximumPath - originalPath . length ) . join ( ' ' ) ;
98
+ if ( size === null || maxSize === null ) {
99
+ continue ;
100
+ } else if ( size < maxSize ) {
101
+ success ++ ;
102
+ console . log ( ` ✔️ ${ compressedPath } ${ prettyBytes ( size ) } ${ green ( '<' ) } ${ prettyBytes ( maxSize ) } ` ) ;
103
+ } else {
104
+ failure ++ ;
105
+ console . log ( ` ❌ ${ compressedPath } ${ prettyBytes ( size ) } ${ red ( '>' ) } ${ prettyBytes ( maxSize ) } ` ) ;
106
+ }
85
107
}
86
108
}
87
109
}
0 commit comments