11'use strict' ;
22
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 ) => {
1613 opt_arg = typeof opt_arg !== 'undefined' ? opt_arg : [ ] ;
17- var stdio = 'inherit' ;
14+ const stdio = 'inherit' ;
1815 if ( opt_io === 'ignore' ) {
1916 stdio = 'ignore' ;
2017 }
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' , ( ) => {
2421 if ( ! running ) {
2522 running = true ;
2623 done ( ) ;
2724 }
2825 } ) ;
29- child . on ( 'error' , function ( ) {
26+ child . on ( 'error' , ( ) => {
3027 if ( ! running ) {
3128 console . error ( 'gulp encountered a child error' ) ;
3229 running = true ;
@@ -35,21 +32,26 @@ var runSpawn = function(done, task, opt_arg, opt_io) {
3532 } ) ;
3633} ;
3734
38- gulp . task ( 'tslint' , function ( ) {
35+ gulp . task ( 'tslint' , ( ) => {
3936 return gulp . src ( [ 'lib/**/*.ts' , 'spec/**/*.ts' , '!spec/install/**/*.ts' ] )
40- . pipe ( tslint ( ) ) . pipe ( tslint . report ( ) ) ;
37+ . pipe ( tslint ( ) )
38+ . pipe ( tslint . report ( ) ) ;
4139} ) ;
4240
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 } ) ) ;
4545} ) ;
4646
47+ gulp . task ( 'lint' , gulp . series ( 'tslint' , 'format:enforce' ) ) ;
48+
4749// prevent contributors from using the wrong version of node
48- gulp . task ( 'checkVersion' , function ( done ) {
50+ gulp . task ( 'checkVersion' , ( done ) => {
4951 // 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 ;
5355
5456 if ( semver . satisfies ( process . version , nodeVersion ) ) {
5557 done ( ) ;
@@ -59,60 +61,40 @@ gulp.task('checkVersion', function(done) {
5961 }
6062} ) ;
6163
62- gulp . task ( 'built:copy' , function ( done ) {
64+ gulp . task ( 'built:copy' , ( ) => {
6365 return gulp . src ( [ 'lib/**/*.js' ] )
6466 . pipe ( gulp . dest ( 'built/' ) ) ;
65- done ( ) ;
66- } ) ;
67-
68- gulp . task ( 'webdriver:update' , function ( done ) {
69- runSpawn ( done , 'node' , [ 'bin/webdriver-manager' , 'update' ] ) ;
7067} ) ;
7168
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/' ) ) ;
7772} ) ;
7873
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' ] ) ;
8477} ) ;
8578
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 ( '.' ) ) ;
9183} ) ;
9284
93- gulp . task ( 'tsc' , function ( done ) {
85+ gulp . task ( 'tsc' , ( done ) => {
9486 runSpawn ( done , 'node' , [ 'node_modules/typescript/bin/tsc' ] ) ;
9587} ) ;
9688
97- gulp . task ( 'tsc:spec' , function ( done ) {
89+ gulp . task ( 'tsc:spec' , ( done ) => {
9890 runSpawn ( done , 'node' , [ 'node_modules/typescript/bin/tsc' , '-p' , 'ts_spec_config.json' ] ) ;
9991} ) ;
10092
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' ) ) ;
10494
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' ) ) ;
11799
118- gulp . task ( 'default' , [ 'prepublish' ] ) ;
100+ gulp . task ( 'default' , gulp . series ( 'prepublish' ) ) ;
0 commit comments