This repository has been archived by the owner on Jul 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 71
/
gulpfile.js
65 lines (58 loc) · 1.77 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
'use strict';
var gulp = require('gulp');
var clangFormat = require('clang-format');
var gulpFormat = require('gulp-clang-format');
var runSequence = require('run-sequence');
var spawn = require('child_process').spawn;
var tslint = require('gulp-tslint');
var runSpawn = function(done, task, opt_arg, opt_io) {
opt_arg = typeof opt_arg !== 'undefined' ? opt_arg : [];
var stdio = 'inherit';
if (opt_io === 'ignore') {
stdio = 'ignore';
}
var child = spawn(task, opt_arg, {stdio: stdio});
var running = false;
child.on('close', function() {
if (!running) {
running = true;
done();
}
});
child.on('error', function() {
if (!running) {
console.error('gulp encountered a child error');
running = true;
done();
}
});
};
gulp.task('tslint', function() {
return gulp.src([
'protractor-typescript/**/*.ts',
'tests/**/*.ts',
'!**/node_modules/**/*.ts'])
.pipe(tslint()).pipe(tslint.report());
});
gulp.task('lint', function(done) {
runSequence('tslint', 'jshint', 'format:enforce', done);
});
gulp.task('jshint', function(done) {
runSpawn(done, 'node', ['node_modules/jshint/bin/jshint', '-c', '.jshintrc',
'jasmine-junit-reports',
'protractor-javascript',
'--exclude=**/node_modules/**/*.js'
]);
});
gulp.task('format:enforce', function() {
var format = require('gulp-clang-format');
var clangFormat = require('clang-format');
return gulp.src(['lib/**/*.ts']).pipe(
format.checkFormat('file', clangFormat, {verbose: true, fail: true}));
});
gulp.task('format', function() {
var format = require('gulp-clang-format');
var clangFormat = require('clang-format');
return gulp.src(['lib/**/*.ts'], { base: '.' }).pipe(
format.format('file', clangFormat)).pipe(gulp.dest('.'));
});