This repository has been archived by the owner on Aug 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
69 lines (58 loc) · 1.83 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
var gulp = require("gulp");
var ts = require("gulp-typescript");
var source = require("vinyl-source-stream");
var mocha = require("gulp-mocha");
var del = require("del");
var listing = require("gulp-task-listing");
var tslint = require("gulp-tslint");
var sourcemaps = require("gulp-sourcemaps");
var path = require("path");
var configTypescript = require("./tsconfig.json").compilerOptions;
configTypescript.typescript = require("typescript");
var tsProject = ts.createProject(configTypescript);
gulp.task("cls", function(){
console.log("\033[2J");
console.log("\033c");
});
gulp.task("build", function() {
return gulp.src(["typings/**/*.d.ts", "src/**/*.ts", "test/**/*.ts"], {base: "."})
.pipe(sourcemaps.init())
.pipe(ts(tsProject))
.pipe(sourcemaps.write(".", {
includeContent: false,
sourceRoot: function(file) {
return file.relative.split(path.sep).map(function(){return ".."}).join("/")+"/../";
}
}))
.pipe(gulp.dest("build/js"));
});
gulp.task("watch", ["build"], function() {
gulp.watch(["src/**/*.ts", "test/**/*.ts"], ["cls", "build"]);
});
gulp.task("test", ["build"], function () { // Release here somehow circumvents clash between mocha and browserify when running the all task
return gulp
.src("build/js/test/**/*.js")
.pipe(mocha({
reporter: "spec"
}));
});
gulp.task("clean", function (callback) {
return del([
"build/*",
"lib/*",
], callback);
});
gulp.task("help", listing);
gulp.task("lint", function () {
return gulp.src(["src/**/*.ts", "test/**/*.ts"])
.pipe(tslint())
.pipe(tslint.report("prose", {
emitError: false
}));
});
gulp.task("release", ["build"], function(){
return gulp.src("build/js/src/**/*.js")
.pipe(gulp.dest("lib"));
});
gulp.task("all", ["build", "test", "release"]);
gulp.task("default", ["release"]);