-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.babel.js
123 lines (104 loc) · 2.71 KB
/
gulpfile.babel.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import gulp from 'gulp';
import ts from 'gulp-typescript';
import ignore from 'gulp-ignore';
import rename from 'gulp-rename';
import merge from 'merge2';
import babel from 'gulp-babel';
import del from 'del';
import jasmine from 'gulp-jasmine';
import typedoc from 'gulp-typedoc';
import jscs from 'gulp-jscs';
import istanbul from 'gulp-istanbul';
import reqDir from 'require-dir';
import {
build as config
} from './package.json';
import {
Instrumenter as isparta
} from 'isparta';
gulp.task('clean', () => {
return del([
config.paths.temp,
config.paths.dist,
config.paths.coverage,
config.paths.docs
], { force: true });
});
function test() {
return gulp.src(`${config.paths.temp}/${config.paths.spec}/**/*.js`)
.pipe(jasmine());
}
gulp.task(test);
/**
gulp.task('style', () => {
return gulp.src(`${config.paths.src}\/**\/*.js`)
.pipe(jscs())
.pipe(jscs.reporter())
.pipe(jscs.reporter('fail'));
});
**/
gulp.task('docs', () => {
var sources = [
config.paths.src,
'./typings/index.d.ts'
];
var options = {
excludeNotExported: true,
tsconfig: `${__dirname}/tsconfig.json`,
mode: 'modules',
out: config.paths.docs
};
return gulp.src(sources)
.pipe(typedoc(options));
});
var tsProject = ts.createProject('tsconfig.json', {
declaration: true
});
gulp.task('compile:ts', () => {
var sources = [
config.paths.src,
'typings/main.d.ts'
];
var compile = tsProject.src(sources)
.pipe(ts(tsProject));
var js = compile.js
.pipe(gulp.dest(config.paths.temp));
var dts = compile.dts
.pipe(ignore.exclude('spec/**'))
.pipe(rename(path => {
path.dirname = path.dirname.replace('src', './');
}))
.pipe(gulp.dest(config.paths.dist));
return merge([js, dts]);
});
gulp.task('compile:es6', () => {
return gulp.src(`${config.paths.temp}/${config.paths.src}/**/*.js`)
.pipe(babel())
.pipe(gulp.dest(config.paths.dist));
});
gulp.task('build', gulp.series('clean', /*'style',*/ 'compile:ts', 'test', 'compile:es6', 'docs'));
gulp.task('default', gulp.task('build'));
gulp.task('watch', () => {
return gulp.watch([config.paths.src, config.paths.spec], gulp.task('build'));
});
const coverage = {
setup() {
return gulp.src(`${config.paths.src}/**/*.js`)
.pipe(istanbul({
instrumenter: isparta,
includeUntested: true
}))
.pipe(istanbul.hookRequire());
},
run() {
return test()
.pipe(istanbul.writeReports({
reporters: ['lcov', 'text'],
reportOpts: { dir: config.paths.coverage }
}));
}
};
gulp.task('coverage', gulp.series(coverage.setup, coverage.run));
try {
reqDir(config.paths.build);
} catch(err) {}