This repository has been archived by the owner on Jun 18, 2019. It is now read-only.
/
build.js
97 lines (80 loc) · 3.11 KB
/
build.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
//******************************************************************************
//* build.js
//*
//* Defines a custom gulp task for compiling TypeScript source code into
//* js files. It outputs the details as to what it generated to the console.
//******************************************************************************
var gulp = require("gulp"),
tsc = require("gulp-typescript"),
config = require('./@configuration.js'),
merge = require("merge2"),
sourcemaps = require('gulp-sourcemaps'),
replace = require('gulp-replace'),
pkg = require("../package.json");
gulp.task("build:lib", () => {
var project = tsc.createProject("tsconfig.json", { declaration: true });
var built = gulp.src(config.paths.sourceGlob)
.pipe(replace("$$Version$$", pkg.version))
.pipe(project());
return merge([
built.dts.pipe(gulp.dest(config.paths.lib)),
built.js.pipe(gulp.dest(config.paths.lib))
]);
});
gulp.task("build:exports", () => {
var project = tsc.createProject("tsconfig.json", { declaration: true });
var built = gulp.src(config.paths.exportsGlob)
.pipe(replace("$$Version$$", pkg.version))
.pipe(project());
return merge([
built.dts.pipe(replace("../", "./lib/")).pipe(gulp.dest(config.paths.exports)),
built.js.pipe(replace("../", "./lib/")).pipe(gulp.dest(config.paths.exports))
]);
});
gulp.task("build:testing", () => {
var projectSrc = tsc.createProject("tsconfig.json");
var projectTests = tsc.createProject("tsconfig.json");
return merge([
gulp.src(config.testing.testsSourceGlob)
.pipe(replace("$$Version$$", pkg.version))
.pipe(projectTests({
compilerOptions: {
types: [
"chai",
"chai-as-promised",
"node",
"mocha"
]
}
}))
.pipe(gulp.dest(config.testing.testingTestsDest)),
gulp.src(config.paths.sourceGlob)
.pipe(projectSrc())
.pipe(gulp.dest(config.testing.testingSrcDest))
]);
});
gulp.task("build:debug", ["clean"], () => {
var srcProject = tsc.createProject("tsconfig.json");
var debugProject = tsc.createProject("tsconfig.json");
let sourceMapSettings = {
includeContent: false,
sourceRoot: (file) => {
return "..\\.." + file.base.replace(file.cwd, "");
}
};
return merge([
gulp.src(config.paths.sourceGlob)
.pipe(replace("$$Version$$", pkg.version))
.pipe(sourcemaps.init())
.pipe(srcProject())
.pipe(sourcemaps.write(".", sourceMapSettings))
.pipe(gulp.dest(config.debug.outputSrc)),
gulp.src(config.debug.debugSourceGlob)
.pipe(sourcemaps.init())
.pipe(debugProject())
.pipe(sourcemaps.write(".", sourceMapSettings))
.pipe(gulp.dest(config.debug.outputDebug))
]);
});
// run the build chain for lib
gulp.task("build", ["clean", "lint", "build:lib", "build:exports"]);