-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
69 lines (61 loc) · 2.25 KB
/
gulpfile.js
File metadata and controls
69 lines (61 loc) · 2.25 KB
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
const gulp = require("gulp");
const ts = require("gulp-typescript");
const tslint = require("gulp-tslint");
const jasmine = require("gulp-jasmine");
const sourcemaps = require('gulp-sourcemaps');
const istanbul = require("gulp-istanbul");
const remapIstanbul = require("remap-istanbul/lib/gulpRemapIstanbul");
const tsProject = ts.createProject("tsconfig.json");
const del = require('del');
gulp.task("coverage-build", function() {
return tsProject.src()
.pipe(sourcemaps.init())
.pipe(tsProject())
.js.pipe(sourcemaps.write('.', {includeContent: false}))
.pipe(gulp.dest("coverage-dist"));
});
gulp.task("pre-coverage", gulp.series("coverage-build"), function() {
return gulp.src(["coverage-dist/**/*.js"])
.pipe(istanbul())
.pipe(istanbul.hookRequire());
});
gulp.task('coverage', gulp.series('coverage-build', 'pre-coverage'), function() {
return gulp.src("coverage-dist/**/*.spec.js")
.pipe(jasmine())
.pipe(istanbul.writeReports({
dir: './coverage',
reporters: ['json'],
reportOpts: {
json: {dir: './coverage', file: 'coverage-js.json'}
}
})).on("end", function () {
return gulp.src('coverage/coverage-js.json')
.pipe(remapIstanbul({
basePath: 'src/',
reports: {
'json': './coverage/coverage.json',
'html': './coverage/html-report',
'lcovonly': './coverage/lcov.info',
'text': null
}
}));
});
});
gulp.task('lint', function() {
return tsProject.src()
.pipe(tslint({"formatter": "verbose"}))
.pipe(tslint.report());
});
gulp.task('test-build', function() {
return tsProject.src()
.pipe(tsProject())
.pipe(gulp.dest("test-dist"));
});
gulp.task('test', gulp.series('test-build'), function() {
return gulp.src("test-dist/**/*.spec.js")
.pipe(jasmine());
});
gulp.task('clean', function(cb) {
del(['dist', 'test-dist', 'coverage-dist', 'coverage']).then(paths => cb());
});
gulp.task('default', gulp.series('test', 'lint', 'coverage'))