2 // https://gist.github.com/2489540
4 /*global config:true, task:true*/
5 module.exports = function( grunt ) {
9 var utils = grunt.utils;
11 var verbose = grunt.verbose;
12 var fail = grunt.fail;
13 var option = grunt.option;
14 var config = grunt.config;
15 var template = grunt.template;
18 pkg: "<json:package.json>",
20 banner: "/*! jQuery v@<%= pkg.version %> jquery.com | jquery.org/license */"
30 "src/sizzle-jquery.js",
31 "src/sizzle/sizzle.js"
47 "src/manipulation.js",
53 { flag: "effects", src: "src/effects.js" },
61 "dist/jquery.min.js": [ "<banner>", "dist/jquery.js" ]
64 files: [ "grunt.js", "dist/jquery.js" ]
67 files: "test/index.html"
70 files: "<config:lint.files>",
106 grunt.registerTask( "default", "selector build:*:* lint min compare_size" );
108 grunt.loadNpmTasks("grunt-compare-size");
110 grunt.registerTask( "testswarm", function( commit, configFile ) {
111 var testswarm = require( "testswarm" ),
113 var tests = "ajax attributes callbacks core css data deferred dimensions effects event manipulation offset queue selector support traversing".split( " " );
114 tests.forEach(function( test ) {
115 testUrls.push( "http://swarm.jquery.org/git/jquery/" + commit + "/test/index.html?filter=" + test );
118 url: "http://swarm.jquery.org/",
120 timeout: 1000 * 60 * 30,
123 authUsername: "jquery",
124 authToken: grunt.file.readJSON( configFile ).jquery.authToken,
125 jobName: 'jQuery commit #<a href="https://github.com/jquery/jquery/commit/' + commit + '">' + commit.substr( 0, 10 ) + '</a>',
128 "runUrls[]": testUrls,
129 "browserSets[]": ["popular"]
133 // Build src/selector.js
134 grunt.registerMultiTask( "selector", "Build src/selector.js", function() {
136 var name = this.file.dest,
137 files = this.file.src,
139 api: file.read( files[0] ),
140 src: file.read( files[1] )
144 // sizzle-jquery.js -> sizzle after "EXPOSE", replace window.Sizzle
145 compiled = sizzle.src.replace( "window.Sizzle = Sizzle;", sizzle.api );
146 verbose.write("Injected sizzle-jquery.js into sizzle.js");
148 // Write concatenated source to file
149 file.write( name, compiled );
151 // Fail task if errors were logged.
152 if ( this.errorCount ) {
156 // Otherwise, print a success message.
157 log.writeln( "File '" + name + "' created." );
161 // Special concat/build task to handle various jQuery build requirements
162 grunt.registerMultiTask(
164 "Concatenate source (include/exclude modules with +/- flags), embed date/version",
166 // Concat specified files.
168 modules = this.flags,
169 optIn = !modules["*"],
170 name = this.file.dest;
172 this.file.src.forEach(function( filepath ) {
173 // Include optional modules per build flags; exclusion trumps inclusion
174 var flag = filepath.flag;
176 if ( modules[ "-" + flag ] ||
177 optIn && !modules[ flag ] && !modules[ "+" + flag ] ) {
179 log.writeln( "Excluding " + filepath.flag + ": '" + filepath.src + "'." );
182 log.writeln( "Including " + filepath.flag + ": '" + filepath.src + "'." );
183 filepath = filepath.src;
186 // Unwrap redundant IIFEs
187 compiled += file.read( filepath ).replace( /^\(function\( jQuery \) \{|\}\)\( jQuery \);\s*$/g, "" );
192 compiled = compiled.replace( "@DATE", new Date() )
193 .replace( "@VERSION", config("pkg.version") );
195 // Write concatenated source to file
196 file.write( name, compiled );
198 // Fail task if errors were logged.
199 if ( this.errorCount ) {
203 // Otherwise, print a success message.
204 log.writeln( "File '" + name + "' created." );