1
1
'use strict' ;
2
2
3
- var gulp = require ( 'gulp' ) ;
4
- var clangFormat = require ( 'clang-format' ) ;
5
- var gulpFormat = require ( 'gulp-clang-format' ) ;
6
- var runSequence = require ( 'run-sequence' ) ;
7
- var spawn = require ( 'child_process' ) . spawn ;
8
- var spawnSync = require ( 'child_process' ) . spawnSync ;
9
- var tslint = require ( 'gulp-tslint' ) ;
10
- var fs = require ( 'fs' ) ;
11
- var path = require ( 'path' ) ;
12
- var glob = require ( 'glob' ) ;
13
- var semver = require ( 'semver' ) ;
14
-
15
- var runSpawn = function ( done , task , opt_arg , opt_io ) {
3
+ const gulp = require ( 'gulp' ) ;
4
+ const format = require ( 'gulp-clang-format' ) ;
5
+ const clangFormat = require ( 'clang-format' ) ;
6
+ const spawn = require ( 'child_process' ) . spawn ;
7
+ const tslint = require ( 'gulp-tslint' ) ;
8
+ const fs = require ( 'fs' ) ;
9
+ const path = require ( 'path' ) ;
10
+ const semver = require ( 'semver' ) ;
11
+
12
+ const runSpawn = ( done , task , opt_arg , opt_io ) => {
16
13
opt_arg = typeof opt_arg !== 'undefined' ? opt_arg : [ ] ;
17
- var stdio = 'inherit' ;
14
+ const stdio = 'inherit' ;
18
15
if ( opt_io === 'ignore' ) {
19
16
stdio = 'ignore' ;
20
17
}
21
- var child = spawn ( task , opt_arg , { stdio : stdio } ) ;
22
- var running = false ;
23
- child . on ( 'close' , function ( ) {
18
+ const child = spawn ( task , opt_arg , { stdio : stdio } ) ;
19
+ let running = false ;
20
+ child . on ( 'close' , ( ) => {
24
21
if ( ! running ) {
25
22
running = true ;
26
23
done ( ) ;
27
24
}
28
25
} ) ;
29
- child . on ( 'error' , function ( ) {
26
+ child . on ( 'error' , ( ) => {
30
27
if ( ! running ) {
31
28
console . error ( 'gulp encountered a child error' ) ;
32
29
running = true ;
@@ -35,21 +32,26 @@ var runSpawn = function(done, task, opt_arg, opt_io) {
35
32
} ) ;
36
33
} ;
37
34
38
- gulp . task ( 'tslint' , function ( ) {
35
+ gulp . task ( 'tslint' , ( ) => {
39
36
return gulp . src ( [ 'lib/**/*.ts' , 'spec/**/*.ts' , '!spec/install/**/*.ts' ] )
40
- . pipe ( tslint ( ) ) . pipe ( tslint . report ( ) ) ;
37
+ . pipe ( tslint ( ) )
38
+ . pipe ( tslint . report ( ) ) ;
41
39
} ) ;
42
40
43
- gulp . task ( 'lint' , function ( done ) {
44
- runSequence ( 'tslint' , 'jshint' , 'format:enforce' , done ) ;
41
+ gulp . task ( 'format:enforce' , ( ) => {
42
+ return gulp . src ( [ 'lib/**/*.ts' ] )
43
+ . pipe ( format . checkFormat ( 'file' , clangFormat ,
44
+ { verbose : true , fail : true } ) ) ;
45
45
} ) ;
46
46
47
+ gulp . task ( 'lint' , gulp . series ( 'tslint' , 'format:enforce' ) ) ;
48
+
47
49
// prevent contributors from using the wrong version of node
48
- gulp . task ( 'checkVersion' , function ( done ) {
50
+ gulp . task ( 'checkVersion' , ( done ) => {
49
51
// read minimum node on package.json
50
- var packageJson = JSON . parse ( fs . readFileSync ( path . resolve ( 'package.json' ) ) ) ;
51
- var protractorVersion = packageJson . version ;
52
- var nodeVersion = packageJson . engines . node ;
52
+ const packageJson = JSON . parse ( fs . readFileSync ( path . resolve ( 'package.json' ) ) ) ;
53
+ const protractorVersion = packageJson . version ;
54
+ const nodeVersion = packageJson . engines . node ;
53
55
54
56
if ( semver . satisfies ( process . version , nodeVersion ) ) {
55
57
done ( ) ;
@@ -59,60 +61,40 @@ gulp.task('checkVersion', function(done) {
59
61
}
60
62
} ) ;
61
63
62
- gulp . task ( 'built:copy' , function ( done ) {
64
+ gulp . task ( 'built:copy' , ( ) => {
63
65
return gulp . src ( [ 'lib/**/*.js' ] )
64
66
. pipe ( gulp . dest ( 'built/' ) ) ;
65
- done ( ) ;
66
- } ) ;
67
-
68
- gulp . task ( 'webdriver:update' , function ( done ) {
69
- runSpawn ( done , 'node' , [ 'bin/webdriver-manager' , 'update' ] ) ;
70
67
} ) ;
71
68
72
- gulp . task ( 'jshint' , function ( done ) {
73
- runSpawn ( done , 'node' , [ 'node_modules/jshint/bin/jshint' , '-c' ,
74
- '.jshintrc' , 'lib' , 'spec' , 'scripts' ,
75
- '--exclude=lib/selenium-webdriver/**/*.js,lib/webdriver-js-extender/**/*.js,' +
76
- 'spec/dependencyTest/*.js,spec/install/**/*.js' ] ) ;
69
+ gulp . task ( 'built:copy:typings' , ( ) => {
70
+ return gulp . src ( [ 'lib/selenium-webdriver/**/*.d.ts' ] )
71
+ . pipe ( gulp . dest ( 'built/selenium-webdriver/' ) ) ;
77
72
} ) ;
78
73
79
- gulp . task ( 'format:enforce' , function ( ) {
80
- var format = require ( 'gulp-clang-format' ) ;
81
- var clangFormat = require ( 'clang-format' ) ;
82
- return gulp . src ( [ 'lib/**/*.ts' ] ) . pipe (
83
- format . checkFormat ( 'file' , clangFormat , { verbose : true , fail : true } ) ) ;
74
+ gulp . task ( 'webdriver:update' , ( done ) => {
75
+ runSpawn ( done , 'node' , [ 'bin/webdriver-manager' , 'update' ,
76
+ '--versions.chrome=2.44' ] ) ;
84
77
} ) ;
85
78
86
- gulp . task ( 'format' , function ( ) {
87
- var format = require ( 'gulp-clang-format' ) ;
88
- var clangFormat = require ( 'clang-format' ) ;
89
- return gulp . src ( [ 'lib/**/*.ts' ] , { base : '.' } ) . pipe (
90
- format . format ( 'file' , clangFormat ) ) . pipe ( gulp . dest ( '.' ) ) ;
79
+ gulp . task ( 'format' , ( ) => {
80
+ return gulp . src ( [ 'lib/**/*.ts' ] , { base : '.' } )
81
+ . pipe ( format . format ( 'file' , clangFormat ) )
82
+ . pipe ( gulp . dest ( '.' ) ) ;
91
83
} ) ;
92
84
93
- gulp . task ( 'tsc' , function ( done ) {
85
+ gulp . task ( 'tsc' , ( done ) => {
94
86
runSpawn ( done , 'node' , [ 'node_modules/typescript/bin/tsc' ] ) ;
95
87
} ) ;
96
88
97
- gulp . task ( 'tsc:spec' , function ( done ) {
89
+ gulp . task ( 'tsc:spec' , ( done ) => {
98
90
runSpawn ( done , 'node' , [ 'node_modules/typescript/bin/tsc' , '-p' , 'ts_spec_config.json' ] ) ;
99
91
} ) ;
100
92
101
- gulp . task ( 'tsc:es5' , function ( done ) {
102
- runSpawn ( done , './scripts/compile_to_es5.sh' ) ;
103
- } ) ;
93
+ gulp . task ( 'prepublish' , gulp . series ( 'checkVersion' , 'tsc' , 'built:copy' ) ) ;
104
94
105
- gulp . task ( 'compile_to_es5' , function ( done ) {
106
- runSequence ( 'checkVersion' , 'tsc:es5' , 'built:copy' , done ) ;
107
- } ) ;
108
-
109
- gulp . task ( 'prepublish' , function ( done ) {
110
- runSequence ( 'checkVersion' , 'tsc' , 'built:copy' , done ) ;
111
- } ) ;
112
-
113
- gulp . task ( 'pretest' , function ( done ) {
114
- runSequence ( 'checkVersion' ,
115
- [ 'tslint' , 'format' ] , 'tsc' , 'built:copy' , 'tsc:spec' , done ) ;
116
- } ) ;
95
+ gulp . task ( 'pretest' , gulp . series (
96
+ 'checkVersion' ,
97
+ gulp . parallel ( 'webdriver:update' , 'tslint' , 'format' ) ,
98
+ 'tsc' , 'built:copy' , 'built:copy:typings' , 'tsc:spec' ) ) ;
117
99
118
- gulp . task ( 'default' , [ 'prepublish' ] ) ;
100
+ gulp . task ( 'default' , gulp . series ( 'prepublish' ) ) ;
0 commit comments