11var path = require ( 'path' ) ;
22var gulp = require ( 'gulp' ) ;
33var babel = require ( 'gulp-babel' ) ;
4- var sequence = require ( 'gulp-sequence' ) ;
54var del = require ( 'del' ) ;
6- var nodeVersion = require ( 'node-version' ) ;
75var execa = require ( 'execa' ) ;
86
97
108var PACKAGE_PARENT_DIR = path . join ( __dirname , '../' ) ;
119var PACKAGE_SEARCH_PATH = ( process . env . NODE_PATH ? process . env . NODE_PATH + path . delimiter : '' ) + PACKAGE_PARENT_DIR ;
1210
1311
14- gulp . task ( 'clean' , function ( ) {
12+ function clean ( ) {
1513 return del ( 'lib' ) ;
16- } ) ;
17-
18- gulp . task ( 'lint' , function ( ) {
19- // TODO: eslint supports node version 4 or higher.
20- // Remove this condition once we get rid of node 0.10 support.
21- if ( nodeVersion . major === '0' )
22- return null ;
14+ }
2315
16+ function lint ( ) {
2417 var eslint = require ( 'gulp-eslint' ) ;
2518
2619 return gulp
@@ -32,14 +25,14 @@ gulp.task('lint', function () {
3225 . pipe ( eslint ( ) )
3326 . pipe ( eslint . format ( ) )
3427 . pipe ( eslint . failAfterError ( ) ) ;
35- } ) ;
28+ }
3629
37- gulp . task ( 'build' , [ 'lint' , 'clean' ] , function ( ) {
30+ function build ( ) {
3831 return gulp
3932 . src ( 'src/**/*.js' )
4033 . pipe ( babel ( ) )
4134 . pipe ( gulp . dest ( 'lib' ) ) ;
42- } ) ;
35+ }
4336
4437function testMocha ( ) {
4538 if ( ! process . env . BROWSERSTACK_USERNAME || ! process . env . BROWSERSTACK_ACCESS_KEY )
@@ -62,17 +55,17 @@ function testMocha () {
6255 return execa ( mochaCmd , mochaOpts , { stdio : 'inherit' } ) ;
6356}
6457
65- gulp . task ( 'test-mocha' , [ 'build' ] , function ( ) {
58+ function testMochaRest ( ) {
6659 process . env . BROWSERSTACK_USE_AUTOMATE = 0 ;
6760
6861 return testMocha ( ) ;
69- } ) ;
62+ }
7063
71- gulp . task ( 'test-mocha-automate' , [ 'build' ] , function ( ) {
64+ function testMochaAutomate ( ) {
7265 process . env . BROWSERSTACK_USE_AUTOMATE = 1 ;
7366
7467 return testMocha ( ) ;
75- } ) ;
68+ }
7669
7770function testTestcafe ( ) {
7871 if ( ! process . env . BROWSERSTACK_USERNAME || ! process . env . BROWSERSTACK_ACCESS_KEY )
@@ -93,16 +86,19 @@ function testTestcafe () {
9386 return execa ( testCafeCmd , testCafeOpts , { stdio : 'inherit' } ) ;
9487}
9588
96- gulp . task ( 'test-testcafe' , [ 'build' ] , function ( ) {
89+ function testTestcafeRest ( ) {
9790 process . env . BROWSERSTACK_USE_AUTOMATE = '0' ;
9891
9992 return testTestcafe ( ) ;
100- } ) ;
93+ }
10194
102- gulp . task ( 'test-testcafe-automate' , [ 'build' ] , function ( ) {
95+ function testTestcafeAutomate ( ) {
10396 process . env . BROWSERSTACK_USE_AUTOMATE = '1' ;
10497
10598 return testTestcafe ( ) ;
106- } ) ;
99+ }
107100
108- gulp . task ( 'test' , sequence ( 'test-mocha' , 'test-mocha-automate' , 'test-testcafe' , 'test-testcafe-automate' ) ) ;
101+ exports . clean = clean ;
102+ exports . lint = lint ;
103+ exports . build = gulp . parallel ( gulp . series ( clean , build ) , lint ) ;
104+ exports . test = gulp . series ( exports . build , testMochaRest , testMochaAutomate , testTestcafeRest , testTestcafeAutomate ) ;
0 commit comments