Selector: add test for jQuery.unique() alias
[jquery.git] / Gruntfile.js
blobb5482829b4bd9999fdf3b3b30fb8885b25de84c8
1 module.exports = function( grunt ) {
2         "use strict";
4         function readOptionalJSON( filepath ) {
5                 var data = {};
6                 try {
7                         data = grunt.file.readJSON( filepath );
8                 } catch ( e ) {}
9                 return data;
10         }
12         var gzip = require( "gzip-js" ),
13                 srcHintOptions = readOptionalJSON( "src/.jshintrc" );
15         // The concatenated file won't pass onevar
16         // But our modules can
17         delete srcHintOptions.onevar;
19         grunt.initConfig({
20                 pkg: grunt.file.readJSON( "package.json" ),
21                 dst: readOptionalJSON( "dist/.destination.json" ),
22                 "compare_size": {
23                         files: [ "dist/jquery.js", "dist/jquery.min.js" ],
24                         options: {
25                                 compress: {
26                                         gz: function( contents ) {
27                                                 return gzip.zip( contents, {} ).length;
28                                         }
29                                 },
30                                 cache: "build/.sizecache.json"
31                         }
32                 },
33                 build: {
34                         all: {
35                                 dest: "dist/jquery.js",
36                                 minimum: [
37                                         "core",
38                                         "selector"
39                                 ],
40                                 // Exclude specified modules if the module matching the key is removed
41                                 removeWith: {
42                                         ajax: [ "manipulation/_evalUrl", "event/ajax" ],
43                                         callbacks: [ "deferred" ],
44                                         css: [ "effects", "dimensions", "offset" ],
45                                         sizzle: [ "css/hiddenVisibleSelectors", "effects/animatedSelector" ]
46                                 }
47                         }
48                 },
49                 npmcopy: {
50                         all: {
51                                 options: {
52                                         destPrefix: "external"
53                                 },
54                                 files: {
55                                         "sizzle/dist": "sizzle/dist",
56                                         "sizzle/LICENSE.txt": "sizzle/LICENSE.txt",
58                                         "npo/npo.js": "native-promise-only/npo.js",
60                                         "qunit/qunit.js": "qunitjs/qunit/qunit.js",
61                                         "qunit/qunit.css": "qunitjs/qunit/qunit.css",
62                                         "qunit/LICENSE.txt": "qunitjs/LICENSE.txt",
64                                         "requirejs/require.js": "requirejs/require.js",
66                                         "sinon/fake_timers.js": "sinon/lib/sinon/util/fake_timers.js",
67                                         "sinon/LICENSE.txt": "sinon/LICENSE"
68                                 }
69                         }
70                 },
71                 jsonlint: {
72                         pkg: {
73                                 src: [ "package.json" ]
74                         },
76                         bower: {
77                                 src: [ "bower.json" ]
78                         }
79                 },
80                 jshint: {
81                         all: {
82                                 src: [
83                                         "src/**/*.js", "Gruntfile.js", "test/**/*.js", "build/**/*.js"
84                                 ],
85                                 options: {
86                                         jshintrc: true
87                                 }
88                         },
89                         dist: {
90                                 src: "dist/jquery.js",
91                                 options: srcHintOptions
92                         }
93                 },
94                 jscs: {
95                         src: "src/**/*.js",
96                         gruntfile: "Gruntfile.js",
98                         // Right now, check only test helpers
99                         test: [ "test/data/testrunner.js" ],
100                         release: [ "build/*.js", "!build/release-notes.js" ],
101                         tasks: "build/tasks/*.js"
102                 },
103                 testswarm: {
104                         tests: [
105                                 "ajax",
106                                 "attributes",
107                                 "callbacks",
108                                 "core",
109                                 "css",
110                                 "data",
111                                 "deferred",
112                                 "dimensions",
113                                 "effects",
114                                 "event",
115                                 "manipulation",
116                                 "offset",
117                                 "queue",
118                                 "selector",
119                                 "serialize",
120                                 "support",
121                                 "traversing"
122                         ]
123                 },
124                 watch: {
125                         files: [ "<%= jshint.all.src %>" ],
126                         tasks: [ "dev" ]
127                 },
128                 uglify: {
129                         all: {
130                                 files: {
131                                         "dist/jquery.min.js": [ "dist/jquery.js" ]
132                                 },
133                                 options: {
134                                         preserveComments: false,
135                                         sourceMap: true,
136                                         sourceMapName: "dist/jquery.min.map",
137                                         report: "min",
138                                         beautify: {
139                                                 "ascii_only": true
140                                         },
141                                         banner: "/*! jQuery v<%= pkg.version %> | " +
142                                                 "(c) jQuery Foundation | jquery.org/license */",
143                                         compress: {
144                                                 "hoist_funs": false,
145                                                 loops: false,
146                                                 unused: false
147                                         }
148                                 }
149                         }
150                 }
151         });
153         // Load grunt tasks from NPM packages
154         require( "load-grunt-tasks" )( grunt );
156         // Integrate jQuery specific tasks
157         grunt.loadTasks( "build/tasks" );
159         grunt.registerTask( "lint", [ "jsonlint", "jshint", "jscs" ] );
161         grunt.registerTask( "test_fast", [ "node_smoke_tests" ] );
163         grunt.registerTask( "test", [ "test_fast", "promises_aplus_tests" ] );
165         // Short list as a high frequency watch task
166         grunt.registerTask( "dev", [ "build:*:*", "lint", "uglify", "remove_map_comment", "dist:*" ] );
168         grunt.registerTask( "default", [ "dev", "test_fast", "compare_size" ] );