This repository has been archived by the owner on Jan 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
/
grunt.js
195 lines (181 loc) · 5.13 KB
/
grunt.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
193
194
195
/*global module:false*/
module.exports = function (grunt) {
'use strict';
var bannerRegex = /\/\*[\s\S]*?\*\//;
grunt.initConfig({
pkg: '<json:package.json>',
meta: {
banner: {
widget: grunt.file.read('lib/jquery.ui.widget.js').match(bannerRegex)[0],
source: grunt.file.read('src/jquery.marcopolo.js').match(bannerRegex)[0]
}
},
lint: {
files: ['grunt.js', 'src/*.js']
},
min: {
widget: {
src: ['<banner:meta.banner.widget>', 'lib/jquery.ui.widget.js'],
dest: 'build/parts/jquery.ui.widget.min.js'
},
source: {
src: ['<banner:meta.banner.source>', 'src/jquery.marcopolo.js'],
dest: 'build/parts/jquery.marcopolo.min.js'
}
},
concat: {
widget: {
src: 'lib/jquery.ui.widget.js',
dest: 'build/parts/jquery.ui.widget.js'
},
source: {
src: ['<banner:meta.banner.source>', '<file_strip_banner:src/jquery.marcopolo.js:block>'],
dest: 'build/parts/jquery.marcopolo.js',
separator: ''
},
unmin: {
src: ['<config:concat.widget.dest>', '<config:concat.source.dest>'],
dest: 'build/jquery.marcopolo.js'
},
min: {
src: ['<config:min.widget.dest>', '<config:min.source.dest>'],
dest: 'build/jquery.marcopolo.min.js',
separator: '\n\n'
}
},
watch: {
files: '<config:lint.files>',
tasks: 'lint'
},
component: {
main: './build/jquery.marcopolo.min.js',
dependencies: {
jquery: '>=1.4.3'
}
},
jasmine: {
all: 'http://localhost:8000/test/runner.html'
},
jshint: {
options: {
// Enforcing
bitwise: true,
camelcase: true,
curly: true,
eqeqeq: true,
forin: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
noempty: true,
nonew: true,
quotmark: 'single',
regexp: true,
undef: true,
unused: true,
strict: true,
trailing: true,
maxlen: 120,
// Relaxing
boss: true,
eqnull: true,
sub: true,
// Environment
browser: true,
jquery: true
},
globals: {
define: true,
process: true
}
},
jqueryjson: {
dependencies: {
jquery: '>=1.4.3'
},
docs: 'https://github.com/jstayton/jquery-marcopolo/blob/master/README.md',
demo: 'http://jstayton.github.com/jquery-marcopolo'
},
'saucelabs-jasmine': {
all: {
testname: 'jquery-marcopolo',
tags: ['master'],
urls: ['<config:jasmine.all>'],
concurrency: 3,
browsers: (function () {
var compact = {
'chrome': {
'*': ['Windows 2008', 'Mac 10.8', 'Linux']
},
'firefox': {
'3.6': 'Windows 2012',
'*': ['Windows 2012', 'Mac 10.6', 'Linux']
},
'internet explorer': {
'6': 'Windows 2003',
'7': 'Windows 2003',
'8': 'Windows 2003',
'9': 'Windows 2008',
'10': 'Windows 2012'
},
'ipad': {
'5.1': 'Mac 10.8',
'6': 'Mac 10.8'
},
'iphone': {
'5.1': 'Mac 10.8',
'6': 'Mac 10.8'
},
'opera': {
'11': 'Windows 2008',
'12': ['Windows 2008', 'Linux']
},
'safari': {
'5': ['Windows 2008', 'Mac 10.6'],
'6': 'Mac 10.8'
}
},
expanded = [];
Object.keys(compact).forEach(function (browserName) {
Object.keys(compact[browserName]).forEach(function (version) {
var platforms = compact[browserName][version];
if (!Array.isArray(platforms)) {
platforms = [platforms];
}
platforms.forEach(function (platform) {
var options = {
browserName: browserName
};
if (version !== '*') {
options.version = version;
}
if (platform) {
options.platform = platform;
}
expanded.push(options);
});
});
});
return expanded;
})()
}
},
server: {
port: 8000,
base: '.'
},
uglify: {}
});
var testTasks = ['lint', 'server', 'jasmine'];
if (process.env.SAUCE_USERNAME && process.env.SAUCE_ACCESS_KEY) {
grunt.loadNpmTasks('grunt-saucelabs');
testTasks.push('saucelabs-jasmine');
}
grunt.registerTask('test', testTasks.join(' '));
grunt.registerTask('default', 'test min concat component jquery-json');
grunt.loadNpmTasks('grunt-bump');
grunt.loadNpmTasks('grunt-jasmine-task');
grunt.loadNpmTasks('grunt-jquery-json');
grunt.loadNpmTasks('grunt-pkg-to-component');
};