-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
58 lines (45 loc) · 1.65 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
var gulp = require("gulp"),
ts = require("gulp-typescript"),
sourcemaps = require("gulp-sourcemaps"),
remapIstanbul = require("remap-istanbul/lib/gulpRemapIstanbul"),
path = require("path"),
KarmaServer = require('karma').Server,
rimraf = require('rimraf');
var tsProject = ts.createProject('tsconfig.json');
gulp.task('clear', function (cb) {
rimraf('./build', cb);
});
gulp.task("build", ["clear"], function() {
var tsResult = tsProject
.src()
.pipe(sourcemaps.init())
.pipe(ts(tsProject))
return tsResult.js
.pipe(sourcemaps.write('.', {
includeContent: false,
sourceRoot: function (file) {
// https://github.com/ivogabe/gulp-typescript/issues/201
var sourceFile = path.join(file.cwd, file.sourceMap.file);
return path.relative(path.dirname(sourceFile), file.cwd);
}
}))
.pipe(gulp.dest('.'));
});
gulp.task("test", ["build"], function(done) {
// https://github.com/karma-runner/gulp-karma
new KarmaServer({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, done).start();
});
gulp.task("test-transform", ["test"], function() {
return gulp.src('./build/**/coverage.json')
.pipe(remapIstanbul({
reports: {
'html': './build/istanbul-html-report',
'json': './build/istanbul-report.json',
'lcovonly': './build/istanbul-lcov-report.info'
}
}));
});
gulp.task("default", ["clear", "build", "test", "test-transform"], function() {});