1- module . exports = function ( grunt ) {
1+ module . exports = grunt => {
22
33"use strict" ;
44
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"
1421 } ,
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"
2027 } ,
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 : { }
2729 } ,
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 = { } ;
2938
3039minify . main . files [ min [ 0 ] ] = [ max [ 0 ] ] ;
3140minify . svg . files [ min [ 1 ] ] = [ max [ 1 ] ] ;
@@ -64,7 +73,7 @@ grunt.initConfig( {
6473 ]
6574 } ,
6675
67- bowercopy : {
76+ npmcopy : {
6877 all : {
6978 options : {
7079 destPrefix : "external"
@@ -74,9 +83,6 @@ grunt.initConfig( {
7483 "qunit/qunit.css" : "qunit/qunit/qunit.css" ,
7584 "qunit/LICENSE.txt" : "qunit/LICENSE.txt" ,
7685
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-
8086 "jquery-1.8.3/jquery.js" : "jquery-1.8.3/jquery.js" ,
8187 "jquery-1.8.3/MIT-LICENSE.txt" : "jquery-1.8.3/MIT-LICENSE.txt" ,
8288
@@ -120,7 +126,10 @@ grunt.initConfig( {
120126 "jquery-3.5.1/LICENSE.txt" : "jquery-3.5.1/LICENSE.txt" ,
121127
122128 "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"
124133 }
125134 }
126135 } ,
@@ -143,6 +152,42 @@ grunt.initConfig( {
143152 }
144153 } ,
145154
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+
146191 qunit : {
147192 files : "test/index.html" ,
148193 options : {
@@ -181,8 +226,8 @@ function gitDate( fn ) {
181226}
182227
183228grunt . 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" ) ;
186231
187232 if ( process . env . COMMIT ) {
188233 version += " " + process . env . COMMIT ;
@@ -209,10 +254,10 @@ grunt.registerTask( "max", function() {
209254
210255grunt . registerTask ( "testswarm" , function ( commit , configFile , projectName , browserSets ,
211256 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 ( ) ;
216261
217262 projectName = projectName || "jquerycolor" ;
218263 config = grunt . file . readJSON ( configFile ) [ projectName ] ;
@@ -228,7 +273,7 @@ grunt.registerTask( "testswarm", function( commit, configFile, projectName, brow
228273 Array . isArray ( browserSets ) ? browserSets [ 0 ] : browserSets ||
229274 "jquery" ] ;
230275
231- tests . forEach ( function ( jQueryVersion ) {
276+ tests . forEach ( jQueryVersion => {
232277 runs [ jQueryVersion ] = config . testUrl + commit +
233278 "/test/index.html?jquery=" + jQueryVersion ;
234279 } ) ;
@@ -248,7 +293,7 @@ grunt.registerTask( "testswarm", function( commit, configFile, projectName, brow
248293 runMax : config . runMax ,
249294 browserSets : browserSets ,
250295 timeout : timeout
251- } , function ( err , passed ) {
296+ } , ( err , passed ) => {
252297 if ( err ) {
253298 grunt . log . error ( err ) ;
254299 }
@@ -257,14 +302,27 @@ grunt.registerTask( "testswarm", function( commit, configFile, projectName, brow
257302 ) ;
258303} ) ;
259304
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+
260310grunt . registerTask ( "default" , [
261311 "eslint" ,
262- "bowercopy " ,
312+ "npmcopy " ,
263313 "qunit" ,
264314 "build" ,
265315 "compare_size"
266316] ) ;
267317grunt . registerTask ( "build" , [ "max" , "concat" , "uglify" ] ) ;
268318grunt . 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" ] ) ;
269327
270328} ;
0 commit comments