|
1 | 1 | 'use strict';
|
2 | 2 |
|
3 | 3 | var gulp = require('gulp');
|
| 4 | +var clangFormat = require('clang-format'); |
| 5 | +var gulpFormat = require('gulp-clang-format'); |
4 | 6 | var runSequence = require('run-sequence');
|
5 |
| -var spawnSync = require('child_process').spawnSync; |
| 7 | +var spawn = require('child_process').spawn; |
| 8 | + |
| 9 | +var runSpawn = function(done, task, opt_arg) { |
| 10 | + var child = spawn(task, opt_arg, {stdio: 'inherit'}); |
| 11 | + child.on('close', function() { |
| 12 | + done(); |
| 13 | + }); |
| 14 | +}; |
6 | 15 |
|
7 | 16 | gulp.task('built:copy', function() {
|
8 |
| - var srcFiles = ['lib/**/*']; |
9 |
| - var dist = 'built/'; |
10 |
| - return gulp.src(srcFiles).pipe(gulp.dest(dist)); |
| 17 | + return gulp.src(['lib/**/*','!lib/**/*.ts']) |
| 18 | + .pipe(gulp.dest('built/')); |
| 19 | +}); |
| 20 | + |
| 21 | +gulp.task('webdriver:update', function(done) { |
| 22 | + runSpawn(done, 'bin/webdriver-manager', ['update']); |
| 23 | +}); |
| 24 | + |
| 25 | +gulp.task('jslint', function(done) { |
| 26 | + runSpawn(done, './node_modules/.bin/jshint', ['lib','spec', 'scripts']); |
| 27 | +}); |
| 28 | + |
| 29 | +gulp.task('clang', function() { |
| 30 | + return gulp.src(['lib/**/*.ts']) |
| 31 | + .pipe(gulpFormat.checkFormat('file', clangFormat)) |
| 32 | + .on('warning', function(e) { |
| 33 | + console.log(e); |
| 34 | + }); |
| 35 | +}); |
| 36 | + |
| 37 | +gulp.task('typings', function(done) { |
| 38 | + runSpawn(done, 'node_modules/.bin/typings', ['install']); |
11 | 39 | });
|
12 | 40 |
|
13 |
| -gulp.task('webdriver:update', function() { |
14 |
| - var child = spawnSync('bin/webdriver-manager', ['update']); |
15 |
| - if (child.stdout != null) { |
16 |
| - console.log(child.stdout.toString()); |
17 |
| - } |
18 |
| - if (child.status !== 0) { |
19 |
| - throw new Error('webdriver-manager update: child error'); |
20 |
| - } |
| 41 | +gulp.task('tsc', function(done) { |
| 42 | + runSpawn(done, 'node_modules/typescript/bin/tsc'); |
21 | 43 | });
|
22 | 44 |
|
23 |
| -gulp.task('jslint', function() { |
24 |
| - var child = spawnSync('./node_modules/.bin/jshint', ['lib','spec', 'scripts']); |
25 |
| - if (child != null && child.stdout != null ) { |
26 |
| - console.log(child.stdout.toString()); |
27 |
| - } |
28 |
| - if (child.status !== 0) { |
29 |
| - throw new Error('jslint: child error'); |
30 |
| - } |
| 45 | +gulp.task('prepublish', function(done) { |
| 46 | + runSequence(['typings', 'jslint', 'clang'],'tsc', 'built:copy', done); |
31 | 47 | });
|
32 | 48 |
|
33 |
| -gulp.task('pretest', function() { |
| 49 | +gulp.task('pretest', function(done) { |
34 | 50 | runSequence(
|
35 |
| - ['webdriver:update', 'jslint'], |
36 |
| - 'built:copy' |
37 |
| - ); |
| 51 | + ['webdriver:update', 'typings', 'jslint', 'clang'], 'tsc', 'built:copy', done); |
38 | 52 | });
|
39 |
| -gulp.task('prepublish', ['built:copy']); |
|
0 commit comments