]> source.dussan.org Git - jquery-ui.git/commitdiff
Remove compare_size; defer to plugin. 633/head
authorRick Waldron waldron.rick@gmail.com <waldron.rick@gmail.com>
Thu, 12 Apr 2012 17:32:11 +0000 (13:32 -0400)
committerRick Waldron waldron.rick@gmail.com <waldron.rick@gmail.com>
Thu, 12 Apr 2012 17:32:11 +0000 (13:32 -0400)
Signed-off-by: Rick Waldron waldron.rick@gmail.com <waldron.rick@gmail.com>
grunt.js
package.json

index 0887cad4c5511a95a9cc4d52871fc8a55e2a1130..83657849ebbfb969d52a5803f843a7b08f84e339 100644 (file)
--- a/grunt.js
+++ b/grunt.js
@@ -70,6 +70,8 @@ cssFiles.forEach(function( file ) {
 
 // csslint and cssmin tasks
 grunt.loadNpmTasks( "grunt-css" );
+// file size comparison tasks
+grunt.loadNpmTasks( "grunt-compare-size" );
 
 grunt.registerHelper( "strip_all_banners", function( filepath ) {
        return grunt.file.read( filepath ).replace( /^\s*\/\*[\s\S]*?\*\/\s*/g, "" );
@@ -537,77 +539,6 @@ grunt.registerTask( "clean", function() {
        require( "rimraf" ).sync( "dist" );
 });
 
-// TODO merge with code in jQuery Core, share as grunt plugin/npm
-// this here actually uses the provided filenames in the output
-// the helpers should just be regular functions, no need to share those with the world
-grunt.registerMultiTask( "compare_size", "Compare size of this branch to master", function() {
-       var files = grunt.file.expandFiles( this.file.src ),
-               done = this.async(),
-               sizecache = __dirname + "/dist/.sizecache.json",
-               sources = {
-                       min: grunt.file.read( files[1] ),
-                       max: grunt.file.read( files[0] )
-               },
-               oldsizes = {},
-               sizes = {};
-
-       try {
-               oldsizes = JSON.parse( grunt.file.read( sizecache ) );
-       } catch( e ) {
-               oldsizes = {};
-       }
-
-       // Obtain the current branch and continue...
-       grunt.helper( "git_current_branch", function( err, branch ) {
-               var key, diff;
-
-               // Derived and adapted from Corey Frang's original `sizer`
-               grunt.log.writeln( "sizes - compared to master" );
-
-               sizes[ files[0] ] = sources.max.length;
-               sizes[ files[1] ] = sources.min.length;
-               sizes[ files[1] + ".gz" ] = grunt.helper( "gzip", sources.min ).length;
-
-               for ( key in sizes ) {
-                       diff = oldsizes[ key ] && ( sizes[ key ] - oldsizes[ key ] );
-                       if ( diff > 0 ) {
-                               diff = "+" + diff;
-                       }
-                       console.log( "%s %s %s",
-                               grunt.helper("lpad",  sizes[ key ], 8 ),
-                               grunt.helper("lpad",  diff ? "(" + diff + ")" : "(-)", 8 ),
-                               key
-                       );
-               }
-
-               if ( branch === "master" ) {
-                       // If master, write to file - this makes it easier to compare
-                       // the size of your current code state to the master branch,
-                       // without returning to the master to reset the cache
-                       grunt.file.write( sizecache, JSON.stringify(sizes) );
-               }
-               done();
-       });
-});
-grunt.registerHelper( "git_current_branch", function( done ) {
-       grunt.utils.spawn({
-               cmd: "git",
-               args: [ "branch", "--no-color" ]
-       }, function( err, result ) {
-               var branch;
-
-               result.split( "\n" ).forEach(function( branch ) {
-                       var matches = /^\* (.*)/.exec( branch );
-                       if ( matches !== null && matches.length && matches[ 1 ] ) {
-                               done( null, matches[ 1 ] );
-                       }
-               });
-       });
-});
-grunt.registerHelper( "lpad", function( str, len, chr ) {
-       return ( Array( len + 1 ).join( chr || " " ) + str ).substr( -len );
-});
-
 grunt.registerTask( "default", "lint csslint qunit build compare_size" );
 grunt.registerTask( "sizer", "concat:ui min:dist/jquery-ui.min.js compare_size" );
 grunt.registerTask( "build", "concat min cssmin" );
index 30e2b4898fd1fd9a1285205bb568a6e5cb616557..1d24c8ab8c448d453afa0d3ba73d57815811cc0e 100644 (file)
@@ -28,8 +28,9 @@
   "devDependencies": {
     "grunt": "0.3.7",
     "grunt-css": "0.1.1",
+    "grunt-compare-size": "0.1.1",
     "request": "2.9.153",
     "rimraf": "2.0.1"
   },
   "keywords": []
-}
\ No newline at end of file
+}