-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
133 lines (113 loc) · 2.4 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
"use strict";
const del = require('del');
const gulp = require("gulp");
const gulpTslint = require("gulp-tslint");
const runSequence = require("run-sequence");
const sourcemaps = require("gulp-sourcemaps");
const tsc = require("gulp-typescript");
const tslint = require("tslint");
const typescript = require('typescript');
// Sources
const SRC_GLOB = 'src/**/*.ts';
const EXAMPLES_GLOB = 'examples/**/**.ts';
const TEST_GLOB = 'test/**/**.ts';
//
// Clean
//
gulp.task("clean", function() {
return del([
"dev", // Development
"dts", // Defintion files
"lib", // Javascript sources
"build", // Build artificats
"coverage" // Coverage reports
]);
});
//
// Lint
//
gulp.task("lint", function() {
const program = tslint.Linter.createProgram("./tsconfig.json");
return gulp.src([
SRC_GLOB,
EXAMPLES_GLOB,
TEST_GLOB,
])
.pipe(gulpTslint({
formatter: "stylish",
program,
}))
.pipe(gulpTslint.report());
});
//
// Build: Universal Module Definition (ES Module, CommonJS, AMD)
//
gulp.task("build-lib", function() {
const project = tsc.createProject("tsconfig.json", {
module : "commonjs",
target: 'es2016',
noEmitOnError: false,
typescript: require("typescript")
});
return gulp.src([
SRC_GLOB
])
.pipe(project())
.js.pipe(gulp.dest("lib"));
});
//
// Build: Typescript DTS declaration file generation
//
gulp.task("build-dts", function() {
const project = tsc.createProject("tsconfig.json", {
declaration: true,
noResolve: false,
typescript: require("typescript")
});
return gulp.src([
SRC_GLOB
])
.pipe(project())
.dts.pipe(gulp.dest("dts"));
});
//
// Build: All
//
gulp.task("build", (done) => {
runSequence(
// "lint",
[
"build-lib",
"build-dts"
],
// "build-test",
done
);
});
//
// Install: All
//
gulp.task("install", (done) => {
runSequence(
"clean",
[
"build-lib",
"build-dts"
],
done
);
});
//
// Test
//
//
// Default
//
gulp.task("default", (done) => {
runSequence(
"clean",
"build",
//"test",
done,
);
});