diff options
author | Rick Waldron waldron.rick@gmail.com <waldron.rick@gmail.com> | 2012-04-12 13:32:11 -0400 |
---|---|---|
committer | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2012-04-12 20:01:40 +0200 |
commit | 9bf90c64f67e32931640200623cdd5a458a5f765 (patch) | |
tree | 4582c59f3a7ff8b910e70133c5c42d0c06e046a6 /grunt.js | |
parent | eaacf82526a6ba67a11a03f981201e1e4f271a5b (diff) | |
download | jquery-ui-9bf90c64f67e32931640200623cdd5a458a5f765.tar.gz jquery-ui-9bf90c64f67e32931640200623cdd5a458a5f765.zip |
Remove compare_size; defer to plugin.
Signed-off-by: Rick Waldron waldron.rick@gmail.com <waldron.rick@gmail.com>
Diffstat (limited to 'grunt.js')
-rw-r--r-- | grunt.js | 73 |
1 files changed, 2 insertions, 71 deletions
@@ -67,6 +67,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, "" ); @@ -508,77 +510,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" ); |