This repository has been archived by the owner on Oct 24, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
57 lines (48 loc) · 1.89 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
var gulp = require("gulp");
var del = require("del");
var mocha = require("gulp-mocha");
var istanbul = require("gulp-istanbul");
var ts = require("gulp-typescript");
var tslint = require("gulp-tslint");
var replace = require("gulp-replace");
var sourcemaps = require("gulp-sourcemaps");
var p = require("./package.json");
var tsNameOf = require("ts-nameof");
gulp.task("typescript", ["clean-scripts"], function() {
var tsProject = ts.createProject("tsconfig.json", {
typescript: require("typescript")
});
return gulp.src(["./src/**/*.ts"])
.pipe(sourcemaps.init())
.pipe(tsNameOf())
.pipe(ts(tsProject))
.pipe(replace(/(var __extends = \(this && this.__extends\))/g, '$1/* istanbul ignore next */'))
.pipe(replace(/(if \(!exports.hasOwnProperty\(p\)\))/g, '/* istanbul ignore else */ $1'))
// ignore empty constructors (for mixins and static classes)
.pipe(replace(/(function [A-Za-z]+\(\) {[\s\n\t]+})/g, '/* istanbul ignore next */ $1'))
.pipe(sourcemaps.write("./"))
.pipe(gulp.dest("./dist"));
});
gulp.task("pre-test", ["typescript"], function () {
return gulp.src(["dist/**/*.js", "!dist/tests/**/*.js"])
.pipe(istanbul())
.pipe(istanbul.hookRequire());
});
gulp.task("test", ["pre-test"], function() {
return gulp.src("dist/tests/**/*.js")
.pipe(mocha({ reporter: "progress" }))
.pipe(istanbul.writeReports())
.pipe(istanbul.enforceThresholds({ thresholds: { global: 90 } }));
});
gulp.task("tslint", function() {
return gulp.src(["./src/**/*.ts", "!./src/typings/**/*.d.ts"])
.pipe(tslint())
.pipe(tslint.report("verbose"));
});
gulp.task("watch", function() {
gulp.watch("./src/**/*.ts", ["tslint", "typescript"]);
});
gulp.task("clean-scripts", function(cb) {
return del(["./dist/**/*"], cb);
});
gulp.task("default", ["tslint", "typescript"]);