1 module.exports = function( grunt ) {
4 function readOptionalJSON( filepath ) {
7 data = JSON.parse( stripJSONComments(
8 fs.readFileSync( filepath, { encoding: "utf8" } )
14 var fs = require( "fs" ),
15 stripJSONComments = require( "strip-json-comments" ),
16 gzip = require( "gzip-js" ),
17 srcHintOptions = readOptionalJSON( "src/.jshintrc" ),
18 newNode = !/^v0/.test( process.version ),
20 // Allow to skip jsdom-related tests in Node.js < 1.0.0
21 runJsdomTests = newNode || ( function() {
30 // The concatenated file won't pass onevar
31 // But our modules can
32 delete srcHintOptions.onevar;
35 pkg: grunt.file.readJSON( "package.json" ),
36 dst: readOptionalJSON( "dist/.destination.json" ),
38 files: [ "dist/jquery.js", "dist/jquery.min.js" ],
41 gz: function( contents ) {
42 return gzip.zip( contents, {} ).length;
45 cache: "build/.sizecache.json"
55 "test/node_smoke_tests/lib/ensure_iterability.js":
56 "test/node_smoke_tests/lib/ensure_iterability_es6.js"
62 dest: "dist/jquery.js",
68 // Exclude specified modules if the module matching the key is removed
70 ajax: [ "manipulation/_evalUrl", "event/ajax" ],
71 callbacks: [ "deferred" ],
72 css: [ "effects", "dimensions", "offset" ],
73 "css/showHide": [ "effects" ],
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/fake_timers.js": "sinon/lib/sinon/util/fake_timers.js",
101 "sinon/LICENSE.txt": "sinon/LICENSE"
107 src: [ "package.json" ]
113 "src/**/*.js", "Gruntfile.js", "test/**/*.js", "build/**/*.js"
120 src: "dist/jquery.js",
121 options: srcHintOptions
126 gruntfile: "Gruntfile.js",
128 // Check parts of tests that pass
130 "test/data/testrunner.js",
131 "test/unit/animation.js",
132 "test/unit/basic.js",
133 "test/unit/tween.js",
141 // A special module with basic tests, meant for
142 // not fully supported environments like Android 2.3,
143 // jsdom or PhantomJS. We run it everywhere, though,
144 // to make sure tests are not broken.
170 files: [ "<%= jshint.all.src %>" ],
176 "dist/jquery.min.js": [ "dist/jquery.js" ]
179 preserveComments: false,
181 sourceMapName: "dist/jquery.min.map",
186 banner: "/*! jQuery v<%= pkg.version %> | " +
187 "(c) jQuery Foundation | jquery.org/license */",
198 // Load grunt tasks from NPM packages
199 require( "load-grunt-tasks" )( grunt );
201 // Integrate jQuery specific tasks
202 grunt.loadTasks( "build/tasks" );
204 grunt.registerTask( "lint", [ "jsonlint", "jshint", "jscs" ] );
206 // Don't run Node-related tests in Node.js < 1.0.0 as they require an old
207 // jsdom version that needs compiling, making it harder for people to compile
208 // jQuery on Windows. (see gh-2519)
209 grunt.registerTask( "test_fast", runJsdomTests ? [ "node_smoke_tests" ] : [] );
211 grunt.registerTask( "test", [ "test_fast" ].concat(
212 runJsdomTests ? [ "promises_aplus_tests" ] : []
215 // Short list as a high frequency watch task
216 grunt.registerTask( "dev", [ "build:*:*", "lint", "uglify", "remove_map_comment", "dist:*" ] );
218 grunt.registerTask( "default", [ "dev", "test_fast", "compare_size" ] );