1
- module . exports = function ( grunt ) {
1
+ module . exports = grunt => {
2
2
3
3
"use strict" ;
4
4
5
- var max = [ "dist/jquery.color.js" , "dist/jquery.color.svg-names.js" ] ,
6
- min = [ "dist/jquery.color.min.js" , "dist/jquery.color.svg-names.min.js" , "dist/jquery.color.plus-names.min.js" ] ,
7
- combined = "dist/jquery.color.plus-names.js" ,
8
- minify = {
9
- main : {
10
- options : {
11
- banner : "/*! jQuery Color v<%= pkg.version %> http://github.com/jquery/jquery-color | jquery.org/license */\n"
12
- } ,
13
- files : { }
5
+ const isBrowserStack = ! ! ( process . env . BROWSER_STACK_USERNAME &&
6
+ process . env . BROWSER_STACK_ACCESS_KEY ) ;
7
+ const max = [
8
+ "dist/jquery.color.js" ,
9
+ "dist/jquery.color.svg-names.js"
10
+ ] ;
11
+ const min = [
12
+ "dist/jquery.color.min.js" ,
13
+ "dist/jquery.color.svg-names.min.js" ,
14
+ "dist/jquery.color.plus-names.min.js"
15
+ ] ;
16
+ const combined = "dist/jquery.color.plus-names.js" ;
17
+ const minify = {
18
+ main : {
19
+ options : {
20
+ banner : "/*! jQuery Color v<%= pkg.version %> http://github.com/jquery/jquery-color | jquery.org/license */\n"
14
21
} ,
15
- svg : {
16
- options : {
17
- banner : "/*! jQuery Color v<%= pkg.version %> SVG Color Names http://github.com/jquery/jquery-color | jquery.org/license */\n"
18
- } ,
19
- files : { }
22
+ files : { }
23
+ } ,
24
+ svg : {
25
+ options : {
26
+ banner : "/*! jQuery Color v<%= pkg.version %> SVG Color Names http://github.com/jquery/jquery-color | jquery.org/license */\n"
20
27
} ,
21
- combined : {
22
- options : {
23
- banner : "/*! jQuery Color v<%= pkg.version %> with SVG Color Names http://github.com/jquery/jquery-color | jquery.org/license */\n"
24
- } ,
25
- files : { }
26
- }
28
+ files : { }
27
29
} ,
28
- concat = { } ;
30
+ combined : {
31
+ options : {
32
+ banner : "/*! jQuery Color v<%= pkg.version %> with SVG Color Names http://github.com/jquery/jquery-color | jquery.org/license */\n"
33
+ } ,
34
+ files : { }
35
+ }
36
+ } ;
37
+ const concat = { } ;
29
38
30
39
minify . main . files [ min [ 0 ] ] = [ max [ 0 ] ] ;
31
40
minify . svg . files [ min [ 1 ] ] = [ max [ 1 ] ] ;
@@ -64,7 +73,7 @@ grunt.initConfig( {
64
73
]
65
74
} ,
66
75
67
- bowercopy : {
76
+ npmcopy : {
68
77
all : {
69
78
options : {
70
79
destPrefix : "external"
@@ -74,9 +83,6 @@ grunt.initConfig( {
74
83
"qunit/qunit.css" : "qunit/qunit/qunit.css" ,
75
84
"qunit/LICENSE.txt" : "qunit/LICENSE.txt" ,
76
85
77
- "jquery-1.7.2/jquery.js" : "jquery-1.7.2/jquery.js" ,
78
- "jquery-1.7.2/MIT-LICENSE.txt" : "jquery-1.7.2/MIT-LICENSE.txt" ,
79
-
80
86
"jquery-1.8.3/jquery.js" : "jquery-1.8.3/jquery.js" ,
81
87
"jquery-1.8.3/MIT-LICENSE.txt" : "jquery-1.8.3/MIT-LICENSE.txt" ,
82
88
@@ -120,7 +126,10 @@ grunt.initConfig( {
120
126
"jquery-3.5.1/LICENSE.txt" : "jquery-3.5.1/LICENSE.txt" ,
121
127
122
128
"jquery-3.6.0/jquery.js" : "jquery-3.6.0/dist/jquery.js" ,
123
- "jquery-3.6.0/LICENSE.txt" : "jquery-3.6.0/LICENSE.txt"
129
+ "jquery-3.6.0/LICENSE.txt" : "jquery-3.6.0/LICENSE.txt" ,
130
+
131
+ "jquery/jquery.js" : "jquery/dist/jquery.js" ,
132
+ "jquery/LICENSE.txt" : "jquery/LICENSE.txt"
124
133
}
125
134
}
126
135
} ,
@@ -143,6 +152,42 @@ grunt.initConfig( {
143
152
}
144
153
} ,
145
154
155
+ karma : {
156
+ options : {
157
+ configFile : "test/karma/karma.conf.js" ,
158
+ singleRun : true
159
+ } ,
160
+ local : {
161
+ browsers : [ "ChromeHeadless" , "FirefoxHeadless" ]
162
+ } ,
163
+ "browserstack-current" : {
164
+ browsers : [
165
+ "bs_chrome-current" ,
166
+ "bs_firefox-current" ,
167
+ "bs_edge-current" ,
168
+ "bs_ie-11" ,
169
+ "bs_opera" ,
170
+ "bs_safari-current" ,
171
+ "bs_ios-current" ,
172
+ "bs_android"
173
+ ]
174
+ } ,
175
+ "browserstack-legacy" : {
176
+ browsers : [
177
+ "bs_chrome-previous" ,
178
+ "bs_firefox-esr" ,
179
+ "bs_firefox-previous" ,
180
+ "bs_edge-18" ,
181
+ "bs_edge-previous" ,
182
+ "bs_ie-9" ,
183
+ "bs_ie-10" ,
184
+ "bs_safari-previous" ,
185
+ "bs_ios-two_versions_back" ,
186
+ "bs_ios-previous"
187
+ ]
188
+ }
189
+ } ,
190
+
146
191
qunit : {
147
192
files : "test/index.html" ,
148
193
options : {
@@ -181,8 +226,8 @@ function gitDate( fn ) {
181
226
}
182
227
183
228
grunt . registerTask ( "max" , function ( ) {
184
- var done = this . async ( ) ,
185
- version = grunt . config ( "pkg.version" ) ;
229
+ const done = this . async ( ) ;
230
+ let version = grunt . config ( "pkg.version" ) ;
186
231
187
232
if ( process . env . COMMIT ) {
188
233
version += " " + process . env . COMMIT ;
@@ -209,10 +254,10 @@ grunt.registerTask( "max", function() {
209
254
210
255
grunt . registerTask ( "testswarm" , function ( commit , configFile , projectName , browserSets ,
211
256
timeout ) {
212
- var config , tests ,
213
- testswarm = require ( "testswarm" ) ,
214
- runs = { } ,
215
- done = this . async ( ) ;
257
+ let config , tests ;
258
+ const testswarm = require ( "testswarm" ) ;
259
+ const runs = { } ;
260
+ const done = this . async ( ) ;
216
261
217
262
projectName = projectName || "jquerycolor" ;
218
263
config = grunt . file . readJSON ( configFile ) [ projectName ] ;
@@ -228,7 +273,7 @@ grunt.registerTask( "testswarm", function( commit, configFile, projectName, brow
228
273
Array . isArray ( browserSets ) ? browserSets [ 0 ] : browserSets ||
229
274
"jquery" ] ;
230
275
231
- tests . forEach ( function ( jQueryVersion ) {
276
+ tests . forEach ( jQueryVersion => {
232
277
runs [ jQueryVersion ] = config . testUrl + commit +
233
278
"/test/index.html?jquery=" + jQueryVersion ;
234
279
} ) ;
@@ -248,7 +293,7 @@ grunt.registerTask( "testswarm", function( commit, configFile, projectName, brow
248
293
runMax : config . runMax ,
249
294
browserSets : browserSets ,
250
295
timeout : timeout
251
- } , function ( err , passed ) {
296
+ } , ( err , passed ) => {
252
297
if ( err ) {
253
298
grunt . log . error ( err ) ;
254
299
}
@@ -257,14 +302,27 @@ grunt.registerTask( "testswarm", function( commit, configFile, projectName, brow
257
302
) ;
258
303
} ) ;
259
304
305
+ grunt . registerTask ( "print_no_browserstack_legacy_message" , ( ) => {
306
+ grunt . log . writeln ( "No BrowserStack credentials detected, running " +
307
+ "tests on legacy browsers skipped..." ) ;
308
+ } ) ;
309
+
260
310
grunt . registerTask ( "default" , [
261
311
"eslint" ,
262
- "bowercopy " ,
312
+ "npmcopy " ,
263
313
"qunit" ,
264
314
"build" ,
265
315
"compare_size"
266
316
] ) ;
267
317
grunt . registerTask ( "build" , [ "max" , "concat" , "uglify" ] ) ;
268
318
grunt . registerTask ( "ci" , [ "eslint" , "qunit" ] ) ;
319
+ grunt . registerTask ( "karma-browserstack-current" , [
320
+ "build" ,
321
+ isBrowserStack ? "karma:browserstack-current" : "karma:local"
322
+ ] ) ;
323
+ grunt . registerTask ( "karma-browserstack-legacy" , isBrowserStack ? [
324
+ "build" ,
325
+ "karma:browserstack-legacy"
326
+ ] : [ "print_no_browserstack_legacy_message" ] ) ;
269
327
270
328
} ;
0 commit comments