1 module.exports = function( grunt ) {
4 function readOptionalJSON( filepath ) {
5 var stripJSONComments = require( "strip-json-comments" ),
8 data = JSON.parse( stripJSONComments(
9 fs.readFileSync( filepath, { encoding: "utf8" } )
15 var fs = require( "fs" ),
16 gzip = require( "gzip-js" ),
17 oldNode = /^v0\./.test( process.version );
19 // Support: Node.js <4
20 // Skip running tasks that dropped support for Node.js 0.12
21 // in this Node version.
22 function runIfNewNode( task ) {
23 return oldNode ? "print_old_node_message:" + task : task;
26 if ( !grunt.option( "filename" ) ) {
27 grunt.option( "filename", "jquery.js" );
31 pkg: grunt.file.readJSON( "package.json" ),
32 dst: readOptionalJSON( "dist/.destination.json" ),
34 files: [ "dist/jquery.js", "dist/jquery.min.js" ],
37 gz: function( contents ) {
38 return gzip.zip( contents, {} ).length;
41 cache: "build/.sizecache.json"
51 "test/node_smoke_tests/lib/ensure_iterability.js":
52 "test/node_smoke_tests/lib/ensure_iterability_es6.js"
58 dest: "dist/jquery.js",
64 // Exclude specified modules if the module matching the key is removed
66 ajax: [ "manipulation/_evalUrl", "event/ajax" ],
67 callbacks: [ "deferred" ],
68 css: [ "effects", "dimensions", "offset" ],
69 "css/showHide": [ "effects" ],
71 remove: [ "ajax", "effects", "queue", "core/ready" ],
72 include: [ "core/ready-no-deferred" ]
74 sizzle: [ "css/hiddenVisibleSelectors", "effects/animatedSelector" ]
81 destPrefix: "external"
84 "sizzle/dist": "sizzle/dist",
85 "sizzle/LICENSE.txt": "sizzle/LICENSE.txt",
87 "npo/npo.js": "native-promise-only/npo.js",
89 "qunit/qunit.js": "qunitjs/qunit/qunit.js",
90 "qunit/qunit.css": "qunitjs/qunit/qunit.css",
91 "qunit/LICENSE.txt": "qunitjs/LICENSE.txt",
93 "qunit-assert-step/qunit-assert-step.js":
94 "qunit-assert-step/qunit-assert-step.js",
95 "qunit-assert-step/MIT-LICENSE.txt":
96 "qunit-assert-step/MIT-LICENSE.txt",
98 "requirejs/require.js": "requirejs/require.js",
100 "sinon/sinon.js": "sinon/pkg/sinon.js",
101 "sinon/LICENSE.txt": "sinon/LICENSE"
107 src: [ "package.json" ]
113 // See https://github.com/sindresorhus/grunt-eslint/issues/119
117 // We have to explicitly declare "src" property otherwise "newer"
118 // task wouldn't work properly :/
120 src: "dist/jquery.js"
123 src: [ "src/**/*.js", "Gruntfile.js", "test/**/*.js", "build/**/*.js" ]
129 // A special module with basic tests, meant for
130 // not fully supported environments like Android 2.3,
131 // jsdom or PhantomJS. We run it everywhere, though,
132 // to make sure tests are not broken.
158 files: [ "<%= eslint.dev.src %>" ],
164 "dist/<%= grunt.option('filename').replace('.js', '.min.js') %>":
165 "dist/<%= grunt.option('filename') %>"
168 preserveComments: false,
172 "dist/<%= grunt.option('filename').replace('.js', '.min.map') %>",
177 banner: "/*! jQuery v<%= pkg.version %> | " +
178 "(c) jQuery Foundation | jquery.org/license */",
189 // Load grunt tasks from NPM packages
190 // Support: Node.js <4
191 // Don't load the eslint task in old Node.js, it won't parse.
192 require( "load-grunt-tasks" )( grunt, {
193 pattern: oldNode ? [ "grunt-*", "!grunt-eslint" ] : [ "grunt-*" ]
196 // Integrate jQuery specific tasks
197 grunt.loadTasks( "build/tasks" );
199 grunt.registerTask( "print_old_node_message", function() {
200 var task = [].slice.call( arguments ).join( ":" );
201 grunt.log.writeln( "Old Node.js detected, running the task \"" + task + "\" skipped..." );
204 grunt.registerTask( "lint", [
206 runIfNewNode( "eslint" )
209 grunt.registerTask( "lint:newer", [
211 runIfNewNode( "newer:eslint" )
214 grunt.registerTask( "test:fast", runIfNewNode( "node_smoke_tests" ) );
215 grunt.registerTask( "test:slow", runIfNewNode( "promises_aplus_tests" ) );
217 grunt.registerTask( "test", [
222 grunt.registerTask( "dev", [
224 runIfNewNode( "newer:eslint:dev" ),
226 "remove_map_comment",
231 grunt.registerTask( "default", [
232 runIfNewNode( "eslint:dev" ),
235 "remove_map_comment",
237 runIfNewNode( "eslint:dist" ),