-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathGruntfile.js
193 lines (173 loc) · 5.05 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/* global module: false, process: false, __dirname: false, require: false */
// Browsers to test on saucelabs
var browsers = {
firefox: [
{
browserName: 'firefox',
platform: 'WIN8.1'
}
],
chrome: [
{
browserName: 'chrome',
platform: 'windows 8.1'
}
],
ie:[
{
browserName: 'internet explorer',
version: '11',
platform: 'WIN8.1'
},
{
browserName: 'internet explorer',
version: '10',
platform: 'WIN8'
},
{
browserName: 'internet explorer',
version: '9',
platform: 'WIN7'
}
],
android: [
{
browserName: 'android',
platform: 'Linux',
version: '4.4',
deviceName: 'Android Emulator'
},
{
browserName: 'android',
platform: 'Linux',
version: '5.0',
deviceName: 'Android Emulator'
},
{
browserName: 'android',
platform: 'Linux',
version: '5.1',
deviceName: 'Android Emulator'
}
],
ios: [
/* Disabled because the tests are failing for reasons unrelated to this lib
{
browserName: 'Safari',
deviceName: 'iPhone Simulator',
deviceOrientation: 'portrait',
platformVersion: '9.3',
platformName: 'iOS'
}
*/
]
};
module.exports = function(grunt) {
"use strict";
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
files: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'],
options: {
bitwise: true,
camelcase: true,
curly: true,
eqeqeq: true,
forin: true,
immed: true,
indent: 4,
latedef: "nofunc",
newcap: true,
noarg: true,
nonew: true,
noempty: true,
undef: true,
unused: true,
strict: true,
trailing: true,
maxlen: 100,
browser: true,
globals: {
"define": true,
"module": true
}
}
},
uglify: {
build: {
src: 'src/picoModal.js',
dest: 'build/picoModal-<%= pkg.version %>.min.js'
}
},
watch: {
files: ['src/**/*.js', 'test/**/*.js'],
tasks: ['default']
},
bowerVerify: {
build: {}
},
domTest: {
files: [ "test/*.js" ]
},
// Register saucelabs configuration for each browser group. This allows
// them to be run individually instead of all or nothing
'sauce-load': {
//mockTunnel: true,
//seleniumHost: 'localhost',
//seleniumPort: 4444,
urls: [ 'http://localhost:8080', 'http://localhost:9090' ],
build: process.env.CI_BUILD_NUMBER || Date.now(),
name: 'PicoModal unit tests',
public: "public",
mode: "followup",
concurrent: 5,
browsers: browsers,
testTimeout: 180000,
setupTimeout: 180000
}
});
grunt.registerTask('server', function () {
var app = require('express')();
app.get('/', function (req, res) {
res.sendFile(__dirname + "/test/index.html");
});
app.get('/picoModal.js', function (req, res) {
res.sendFile(__dirname + "/src/picoModal.js");
});
app.listen(9090);
});
// Plugins
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-bower-verify');
grunt.loadNpmTasks('grunt-dom-test');
grunt.loadNpmTasks('grunt-continue');
grunt.loadNpmTasks('grunt-sauce-load');
// Default task(s).
grunt.registerTask(
'default',
['jshint', 'uglify', 'domTest:test']);
grunt.registerTask( 'dev', [
'server', 'domTest:server', 'continue:on',
'jshint', 'uglify', 'domTest:test',
'watch']);
grunt.registerTask(
'sauce',
['default', 'server', 'domTest:server', 'sauce-load']);
// Register a grunt target for testing individual browser groups
Object.keys(browsers).forEach(function (browser) {
grunt.registerTask(
browser,
['default', 'server', 'domTest:server', 'sauce-load:' + browser]);
});
// Pull requests don't have access to saucelabs, so we need
// to disable that
grunt.registerTask('travis', [
process.env.TRAVIS_PULL_REQUEST === "false" ?
'sauce' :
'default'
]);
};