mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Build: Fixing the sizer script to handle this many files
(cherry picked from commit f6c12849f1
)
This commit is contained in:
parent
6cd672b660
commit
e7702c1c14
@ -2,7 +2,8 @@ var fs = require( "fs" ),
|
||||
stdin = process.openStdin(),
|
||||
rsize = /(\d+).*?(jquery\S+)/g,
|
||||
oldsizes = {},
|
||||
sizes = {};
|
||||
sizes = {},
|
||||
input = "";
|
||||
|
||||
try {
|
||||
oldsizes = JSON.parse( fs.readFileSync( __dirname + "/.sizecache.json", "utf8" ) );
|
||||
@ -10,26 +11,27 @@ try {
|
||||
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( "data" , function( chunk ) {
|
||||
input += chunk;
|
||||
});
|
||||
stdin.on( "end", function() {
|
||||
var match;
|
||||
|
||||
while ( match = rsize.exec( input ) ) {
|
||||
sizes[ match[2] ] = parseInt( match[1], 10 );
|
||||
}
|
||||
|
||||
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 );
|
||||
console.log( "%s %s %s", lpad( sizes[ key ], 8 ), lpad( oldsizes[key] ? "(" + diff + ")" : "(-)", 8 ), key );
|
||||
}
|
||||
process.exit();
|
||||
});
|
Loading…
Reference in New Issue
Block a user