-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
84 lines (72 loc) · 2.24 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
import gulp from 'gulp';
import tsc from 'gulp-typescript';
import tslint from 'gulp-tslint';
import sourcemaps from 'gulp-sourcemaps';
import mocha from 'gulp-mocha';
import cached from 'gulp-cached';
import istanbul from 'gulp-istanbul'
import coveralls from 'gulp-coveralls';
import remapIstanbul from 'remap-istanbul/lib/gulpRemapIstanbul';
import merge from 'merge-stream';
import del from 'del';
import path from 'path';
const dist = './dist';
const sourceFiles = './src/**/*.ts';
const testSpecs = './dist/**/*.spec.js';
const testSources = ['./dist/**/*.js', `!${testSpecs}`];
const coverageDir = './.coverage'
const lcovFile = path.join(coverageDir, 'lcov.info');
gulp.task('clean', () => {
return del([`${dist}/*`]);
});
gulp.task('tslint', () => {
return gulp.src(sourceFiles)
.pipe(cached('tslint'))
.pipe(tslint({
formatter: "verbose"
})).pipe(tslint.report({
emitError: false
}));
});
const tsproject = tsc.createProject('tsconfig.json');
gulp.task('assemble', ['clean', 'tslint'], () => {
const source = gulp.src(sourceFiles)
.pipe(sourcemaps.init())
.pipe(tsproject())
return merge(source.js, source.dts)
.pipe(sourcemaps.write('./', {
includeContent: false,
sourceRoot: '../src'
}))
.pipe(gulp.dest(dist));
});
gulp.task('test:run', ['assemble'], () => {
return gulp.src(testSpecs)
.pipe(mocha());
});
gulp.task('cover:instrument', ['assemble'], () => {
return gulp.src(testSources)
.pipe(istanbul())
.pipe(istanbul.hookRequire());
});
gulp.task('cover:run', ['cover:instrument'], () => {
return gulp.src(testSpecs)
.pipe(mocha())
.pipe(istanbul.writeReports({
dir: coverageDir,
reporters: ['json']
}));
});
gulp.task('cover:report', ['cover:run'], () => {
return gulp.src(path.join(coverageDir, 'coverage-final.json'))
.pipe(remapIstanbul({
reports: { html: coverageDir, lcovonly: lcovFile }
}));
});
gulp.task('cover:coveralls', ['cover:report'], () => {
return gulp.src(lcovFile)
.pipe(coveralls());
});
gulp.task('watch', ['assemble'], () => {
return gulp.watch(sourceFiles, ['assemble']);
});