diff options
author | Rick Waldron <waldron.rick@gmail.com> | 2012-06-04 12:48:18 -0400 |
---|---|---|
committer | Rick Waldron <waldron.rick@gmail.com> | 2012-06-04 12:48:18 -0400 |
commit | 7c23b77af2477417205fda9bde5208a81e57e40e (patch) | |
tree | d325a34f92a4792fc5ee6aee8266b86bd0e25a98 /grunt.js | |
parent | 9a3046c3752b80da7526dce34968b8422f3d92f8 (diff) | |
download | jquery-7c23b77af2477417205fda9bde5208a81e57e40e.tar.gz jquery-7c23b77af2477417205fda9bde5208a81e57e40e.zip |
Strips IIFEs from modules; Always require built jQuery for tests.
Diffstat (limited to 'grunt.js')
-rw-r--r-- | grunt.js | 67 |
1 files changed, 58 insertions, 9 deletions
@@ -13,6 +13,10 @@ module.exports = function( grunt ) { var option = grunt.option; var config = grunt.config; var template = grunt.template; + var distpaths = [ + "dist/jquery.js", + "dist/jquery.min.js" + ]; grunt.initConfig({ pkg: "<json:package.json>", @@ -20,10 +24,7 @@ module.exports = function( grunt ) { banner: "/*! jQuery v@<%= pkg.version %> jquery.com | jquery.org/license */" }, compare_size: { - files: [ - "dist/jquery.js", - "dist/jquery.min.js" - ] + files: distpaths }, selector: { "src/selector.js": [ @@ -67,8 +68,8 @@ module.exports = function( grunt ) { files: "test/index.html" }, watch: { - files: "<config:lint.files>", - tasks: "concat lint" + files: [ "<config:lint.files>", "src/**/*.js" ], + tasks: "default" }, jshint: { options: { @@ -103,7 +104,7 @@ module.exports = function( grunt ) { }); // Default grunt. - grunt.registerTask( "default", "selector build:*:* lint min compare_size" ); + grunt.registerTask( "default", "submodules selector build:*:* dist:* lint min compare_size" ); grunt.loadNpmTasks("grunt-compare-size"); @@ -184,13 +185,14 @@ module.exports = function( grunt ) { } // Unwrap redundant IIFEs - compiled += file.read( filepath ).replace( /^\(function\( jQuery \) \{|\}\)\( jQuery \);\s*$/g, "" ); + compiled += file.read( filepath ); + //.replace( /^\(function\( jQuery \) \{|\}\)\( jQuery \);\s*$/g, "" ); }); // Embed Date // Embed Version compiled = compiled.replace( "@DATE", new Date() ) - .replace( "@VERSION", config("pkg.version") ); + .replace( "@VERSION", config("pkg.version") ); // Write concatenated source to file file.write( name, compiled ); @@ -203,4 +205,51 @@ module.exports = function( grunt ) { // Otherwise, print a success message. log.writeln( "File '" + name + "' created." ); }); + + grunt.registerTask( "submodules", function() { + var done = this.async(); + + grunt.verbose.write( "Updating submodules..." ); + + // TODO: migrate remaining `make` to grunt tasks + // + grunt.utils.spawn({ + cmd: "make" + }, function( err, result ) { + if ( err ) { + grunt.verbose.error(); + done( err ); + return; + } + + grunt.log.writeln( result ); + + done(); + }); + }); + + // Allow custom dist file locations + grunt.registerTask( "dist", function() { + var keys, dir; + + keys = Object.keys( this.flags ); + + if ( keys.length ) { + dir = keys[0]; + + if ( !/\/$/.test( dir ) ) { + dir += "/"; + } + + // 'distpaths' is declared at the top of the + // module.exports function scope. + distpaths.forEach(function( filename ) { + var created = dir + filename.replace( "dist/", "" ); + + file.write( created, file.read( filename ) ); + + log.writeln( "File '" + created + "' created." ); + }); + } + }); }; |