-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
139 lines (119 loc) · 3.06 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
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/**
* Created by Ab on 9-4-2015.
*/
var gulp = require("gulp");
var runSequence = require("run-sequence");
var del = require("del");
var merge = require("merge2");
var ts = require("gulp-typescript");
var tslint = require("gulp-tslint");
var sourcemaps = require("gulp-sourcemaps");
var mocha = require("gulp-spawn-mocha");
// swallow errors in watch
function swallowError (error) {
//If you want details of the error in the console
console.log(error.toString());
this.emit("end");
}
//define typescript project
var tsProject = ts.createProject({
module: "commonjs",
target: "es6",
declaration: false
});
gulp.task("default", ["build:clean"]);
// gulp.task("default", done => {
// runSequence("clean", "compile", "test", done);
// });
gulp.task("build", done => {
runSequence("compile", "test:dot", done);
});
gulp.task("build:clean", done => {
runSequence("clean", "compile", "test:integration", done);
});
gulp.task("watch", ["clean", "build"], function () {
gulp.watch("src/**/*.ts", ["build"]);
});
gulp.task("clean", function (cb) {
del.sync([
"coverage",
"build"
]);
cb();
});
gulp.task("clean:all", function () {
del([
"coverage",
"build",
"node_modules"
]);
});
gulp.task("compile", function () {
// compile typescript
var tsResult = gulp.src("src/**/*.ts")
.pipe(tslint({
// configuration: "tools/tslint-node.json"
formatter: "verbose"
}))
.pipe(tslint.report())
.pipe (sourcemaps.init())
.pipe (tsProject());
return merge([
tsResult.js
.pipe(sourcemaps.write(".", {
includeContent: false,
sourceRoot: "../src/"
}))
.pipe(gulp.dest("build")),
tsResult.dts.pipe(gulp.dest("build"))
]);
});
gulp.task("lint", function () {
return gulp.src("src/**/*.ts")
.pipe(tslint({
configuration: "tsconfig.json"
}))
.pipe(tslint.report("full"));
});
// unit tests, more a fast integration test because at the moment it uses an external AMQP server
gulp.task("test", ["compile"], function () {
console.log("starting test!");
return gulp.src("build/**/*.spec.js", {
read: false
})
.pipe(mocha({
r: "tools/mocha-setup.js",
reporter: "spec" // "spec", "dot"
}))
.on("error", swallowError);
});
// unit tests, more a fast integration test because at the moment it uses an external AMQP server
gulp.task("test:dot", function () {
return gulp.src("build/**/*.spec.js", {
read: false
})
.pipe(mocha({
r: "tools/mocha-setup.js",
reporter: "dot" // "spec", "dot"
}))
.on("error", swallowError);
});
// integration tests, at the moment more an extended version of the unit tests
gulp.task("test:integration", function () {
return gulp.src(["build/**/*.spec.js", "build/**/*.spec-i.js"], {
read: false
})
.pipe(mocha({
reporter: "dot" // "spec", "dot"
}))
.on("error", swallowError);
});
gulp.task("test:coverage", function () {
return gulp.src("build/**/*.spec.js", {
read: false
})
.pipe(mocha({
reporter: "spec", // "spec", "dot"
istanbul: true
}));
});