@@ -149,11 +149,12 @@ export function showDirStats(dirPath: string): void {
149149 const ext = name . split ( '.' ) . slice ( 1 ) . join ( '.' ) ;
150150 const filetype = ext ? '*.' + ext : name ;
151151
152- fileTypes [ filetype ] ??= { filepaths : [ ] , size : 0 } ;
152+ const dirStats = fileTypes [ filetype ] ?? { filepaths : [ ] , size : 0 } ;
153+ fileTypes [ filetype ] = dirStats ;
153154
154155 totalSize += stats . size ;
155- fileTypes [ filetype ] . size += stats . size ;
156- fileTypes [ filetype ] . filepaths . push ( filepath ) ;
156+ dirStats . size += stats . size ;
157+ dirStats . filepaths . push ( filepath ) ;
157158 }
158159
159160 const stats : Array < [ string , number ] > = [ ] ;
@@ -163,13 +164,14 @@ export function showDirStats(dirPath: string): void {
163164 if ( numFiles > 1 ) {
164165 stats . push ( [ filetype + ' x' + numFiles , typeStats . size ] ) ;
165166 } else {
167+ assert ( typeStats . filepaths [ 0 ] ) ;
166168 const relativePath = path . relative ( dirPath , typeStats . filepaths [ 0 ] ) ;
167169 stats . push ( [ relativePath , typeStats . size ] ) ;
168170 }
169171 }
170172 stats . sort ( ( a , b ) => b [ 1 ] - a [ 1 ] ) ;
171173
172- const prettyStats = stats . map ( ( [ type , size ] ) => [
174+ const prettyStats = stats . map < [ string , string ] > ( ( [ type , size ] ) => [
173175 type ,
174176 ( size / 1024 ) . toFixed ( 2 ) + ' KB' ,
175177 ] ) ;
0 commit comments