3 module.exports = function(grunt) {
5 grunt.loadNpmTasks('grunt-contrib-uglify');
7 require('load-grunt-tasks')(grunt);
8 var YAML = require('js-yaml');
9 var fs = require('fs');
10 var browser = process.env.BROWSER;
11 var travisBuild = process.env.BUILD;
12 var pullRequest = process.env.TRAVIS_PULL_REQUEST;
13 var ymlPackage = YAML.safeLoad(fs.readFileSync('package.yml', 'utf8'));
19 // We use end2end task (which does not start the webserver)
20 // and start the webserver as a separate process
21 // to avoid https://github.com/joyent/libuv/issues/826
24 middleware: function(connect, options) {
26 function(req, resp, next) {
27 // cache get requests to speed up tests on travis
28 if (req.method === 'GET') {
29 resp.setHeader('Cache-control', 'public, max-age=3600');
34 connect.static(options.base)
48 src: ymlPackage.sources,
49 dest: 'mootools-all.js'
55 only: '<%= grunt.option("file") && "Core/" + grunt.option("file") %>'
57 src: ymlPackage.sources,
58 dest: 'mootools-nocompat.js'
65 src: 'Specs/<%= grunt.option("module") || "**" %>/<%= grunt.option("file") || "*" %>.js',
66 dest: 'mootools-specs.js'
73 only: '<%= grunt.option("file") && "Specs/" + grunt.option("file") %>'
76 dest: 'mootools-specs.js'
82 only: '<%= grunt.option("file") && "Core/" + grunt.option("file") %>'
84 src: ymlPackage.sources,
85 dest: 'dist/mootools-core.js'
89 src: ymlPackage.sources,
90 dest: 'dist/mootools-core-compat.js'
102 {'dist/mootools-core.min.js': ['dist/mootools-core.js']},
103 {'dist/mootools-core-compat.min.js': ['dist/mootools-core-compat.js']}
111 captureTimeout: 60000 * 2,
113 frameworks: ['jasmine', 'sinon'],
114 files: ['Tests/Utilities/*.js', 'mootools-*.js'],
116 username: process.env.SAUCE_USERNAME,
117 accessKey: process.env.SAUCE_ACCESS_KEY,
118 testName: 'MooTools-Core. Build: ' + travisBuild + '. Browser: ' + browser
120 reporters: ['progress', 'saucelabs'],
124 browserName: 'chrome',
129 browserName: 'firefox',
134 browserName: 'opera',
135 platform: 'Windows 2008',
140 browserName: 'safari',
141 platform: 'OS X 10.9',
146 browserName: 'safari',
147 platform: 'OS X 10.8',
152 browserName: 'safari',
154 platform: 'OS X 10.6'
158 browserName: 'safari',
160 platform: 'Windows 7'
164 browserName: 'internet explorer',
165 platform: 'Windows 8.1',
170 browserName: 'internet explorer',
171 platform: 'Windows 8',
176 browserName: 'internet explorer',
177 platform: 'Windows 7',
182 browserName: 'internet explorer',
183 platform: 'Windows 7',
188 browserName: 'internet explorer',
189 platform: 'Windows XP',
194 browserName: 'internet explorer',
195 platform: 'Windows XP',
200 browserName: 'iphone',
201 platform: 'OS X 10.9',
203 deviceOrientation: 'portrait'
207 browserName: 'iphone',
208 platform: 'OS X 10.8',
210 deviceOrientation: 'portrait'
214 browserName: 'iphone',
215 platform: 'OS X 10.8',
217 deviceOrientation: 'portrait'
223 browsers: ['PhantomJS']
232 browsers: ['PhantomJS'],
236 // Testers for dist build files
239 browsers: ['PhantomJS'],
240 files: ['dist/mootools-core-compat.js', 'mootools-specs.js', 'Tests/Utilities/*.js']
245 browsers: ['PhantomJS'],
246 files: ['dist/mootools-core-compat.min.js', 'mootools-specs.js', 'Tests/Utilities/*.js']
251 browsers: ['PhantomJS'],
252 files: ['dist/mootools-core.js', 'mootools-specs.js', 'Tests/Utilities/*.js']
257 browsers: ['PhantomJS'],
258 files: ['dist/mootools-core.min.js', 'mootools-specs.js', 'Tests/Utilities/*.js']
264 dist: {src: 'dist/mootools-*.js'},
265 specs: {src: 'mootools-*.js'}
270 var compatBuild = ['clean:specs', 'packager:all', 'packager:specs'];
271 var nocompatBuild = ['clean:specs', 'packager:nocompat', 'packager:specs-nocompat'];
272 var tasks = travisBuild == 'default' ? compatBuild : nocompatBuild;
273 tasks = pullRequest != 'false' ? tasks.concat('karma:continuous') : tasks.concat('karma:sauceTask');
275 grunt.registerTask('default', compatBuild.concat('karma:continuous'));
276 grunt.registerTask('nocompat', nocompatBuild.concat('karma:continuous'));
277 grunt.registerTask('default:travis', tasks);
278 grunt.registerTask('distBuild', [
280 'clean:dist', 'packager:dist-all', 'packager:dist-nocompat', 'uglify',
281 // Test specs against dist files
282 'clean:specs', 'packager:specs', 'karma:compatFull', 'karma:compatUglyfied',
283 'clean:specs', 'packager:specs-nocompat', 'karma:nocompatFull', 'karma:nocompatUglified'