diff options
author | Corey Frang <gnarf@gnarf.net> | 2011-09-19 15:27:43 -0400 |
---|---|---|
committer | timmywil <timmywillisn@gmail.com> | 2011-09-19 15:27:43 -0400 |
commit | 61277d2864b00c5206d0fdcefc67f7497663a012 (patch) | |
tree | 76a2c944de342b6e83feb0717fed61c7ee9564d9 /build | |
parent | 8f447576c918e3004ea479c278c11677920dc41a (diff) | |
download | jquery-61277d2864b00c5206d0fdcefc67f7497663a012.tar.gz jquery-61277d2864b00c5206d0fdcefc67f7497663a012.zip |
Landing pull request 511. Adding a little Makefile jQuery sizing utility to easily see differences in size between makes. Fixes #10308.
More Details:
- https://github.com/jquery/jquery/pull/511
Diffstat (limited to 'build')
-rw-r--r-- | build/sizer.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/build/sizer.js b/build/sizer.js new file mode 100644 index 000000000..2372b5fd3 --- /dev/null +++ b/build/sizer.js @@ -0,0 +1,36 @@ +var fs = require( "fs" ), + stdin = process.openStdin(), + rsize = /(\d+).*?(jquery\S+)/g, + oldsizes = {}, + sizes = {}; + +try { + oldsizes = JSON.parse( fs.readFileSync( __dirname + "/.sizecache.json", "utf8" ) ); +} catch(e) { + oldsizes = {}; +}; + +stdin.on( "data" , function( chunk ) { + var match; + + while ( match = rsize.exec( chunk ) ) { + sizes[ match[2] ] = parseInt( match[1], 10 ); + } +}); + +function lpad( str, len, chr ) { + return ( Array(len+1).join( chr || " ") + str ).substr( -len ); +} + +stdin.on( "end", function() { + console.log( "jQuery Size - compared to last make" ); + fs.writeFileSync( __dirname + "/.sizecache.json", JSON.stringify( sizes, true ), "utf8" ); + for ( var key in sizes ) { + var diff = oldsizes[ key ] && ( sizes[ key ] - oldsizes[ key ] ); + if ( diff > 0 ) { + diff = "+" + diff; + } + console.log( "%s %s %s", lpad( sizes[ key ], 8 ), lpad( diff ? "(" + diff + ")" : "(-)", 8 ), key ); + } + process.exit(); +});
\ No newline at end of file |