33 Author Tobias Koppers @sokra
44*/
55var RequestShortener = require ( "./RequestShortener" ) ;
6+ var formatSize = require ( "./SizeFormatHelpers" ) . formatSize ;
67
78function Stats ( compilation ) {
89 this . compilation = compilation ;
@@ -424,7 +425,7 @@ Stats.jsonToString = function jsonToString(obj, useColors) {
424425 }
425426 for ( row = 0 ; row < rows ; row ++ ) {
426427 for ( col = 0 ; col < cols ; col ++ ) {
427- var format = row === 0 ? colors . bold : array [ row ] [ col ] . color ;
428+ var format = array [ row ] [ col ] . color ;
428429 value = getText ( array , row , col ) + "" ;
429430 var l = value . length ;
430431 if ( align [ col ] === "l" )
@@ -440,16 +441,6 @@ Stats.jsonToString = function jsonToString(obj, useColors) {
440441 }
441442 }
442443
443- function formatSize ( size ) {
444- if ( size <= 0 ) return "0 bytes" ;
445-
446- var abbreviations = [ "bytes" , "kB" , "MB" , "GB" ] ;
447- var index = Math . floor ( Math . log ( size ) / Math . log ( 1000 ) ) ;
448-
449- return + ( size / Math . pow ( 1000 , index ) )
450- . toPrecision ( 3 ) + " " + abbreviations [ index ] ;
451- }
452-
453444 function getAssetColor ( asset , defaultColor ) {
454445 if ( asset . isOverSizeLimit ) {
455446 return colors . yellow ;
@@ -484,25 +475,20 @@ Stats.jsonToString = function jsonToString(obj, useColors) {
484475 if ( obj . assets && obj . assets . length > 0 ) {
485476 var t = [
486477 [
487- { value : "Asset" , color : colors . normal } ,
488- { value : "Size" , color : colors . normal } ,
489- { value : "Chunks" , color : colors . normal } ,
490- { value : "" , color : colors . normal } ,
491- { value : "Chunk Names" , color : colors . normal }
478+ { value : "Asset" , color : colors . bold } ,
479+ { value : "Size" , color : colors . bold } ,
480+ { value : "Chunks" , color : colors . bold } ,
481+ { value : "" , color : colors . bold } ,
482+ { value : "Chunk Names" , color : colors . bold }
492483 ]
493484 ] ;
494485 obj . assets . forEach ( function ( asset ) {
495- t . push ( [ {
496- value : asset . name , color : getAssetColor ( asset , colors . green )
497- } , {
498- value : formatSize ( asset . size ) , color : getAssetColor ( asset , colors . normal )
499- } , {
500- value : asset . chunks . join ( ", " ) , color : colors . bold
501- } , {
502- value : asset . emitted ? "[emitted]" : "" , color : colors . green
503- } , {
504- value : asset . chunkNames . join ( ", " ) , color : colors . normal
505- }
486+ t . push ( [
487+ { value : asset . name , color : getAssetColor ( asset , colors . green ) } ,
488+ { value : formatSize ( asset . size ) , color : getAssetColor ( asset , colors . normal ) } ,
489+ { value : asset . chunks . join ( ", " ) , color : colors . bold } ,
490+ { value : asset . emitted ? "[emitted]" : "" , color : colors . green } ,
491+ { value : asset . chunkNames . join ( ", " ) , color : colors . normal }
506492 ] ) ;
507493 } ) ;
508494 table ( t , "rrrll" ) ;
0 commit comments