1 | var gulp = require("gulp");
|
2 | var fs = require("fs");
|
3 | var del = require("del");
|
4 | var ts = require("gulp-typescript");
|
5 | var merge = require("merge2");
|
6 |
|
7 | var config = JSON.parse(fs.readFileSync(__dirname + "/tsconfig.json"));
|
8 |
|
9 | gulp.task("default", function() {
|
10 | console.log("Main commands:");
|
11 | console.log("build build the lynx library");
|
12 | console.log("\n");
|
13 | console.log("Other commands:");
|
14 | console.log(
|
15 | "compile compile all the typescript files to the dist folder"
|
16 | );
|
17 | console.log(
|
18 | "copy copy all the files (!.ts) from the source folder to the dist folder"
|
19 | );
|
20 | console.log("clean delete the dist folder");
|
21 | });
|
22 |
|
23 | gulp.task("copy", function() {
|
24 | return gulp
|
25 | .src(["lynx/**", "!lynx/**/*.ts"])
|
26 | .pipe(gulp.dest(config.compilerOptions.outDir));
|
27 | });
|
28 |
|
29 | gulp.task("clean", function() {
|
30 | return del(config.compilerOptions.outDir);
|
31 | });
|
32 |
|
33 | gulp.task("compile", function() {
|
34 | var tsProject = ts.createProject(__dirname + "/tsconfig.json");
|
35 | var tsResult = tsProject.src().pipe(tsProject());
|
36 | return merge([
|
37 | tsResult.js.pipe(gulp.dest(config.compilerOptions.outDir)),
|
38 | tsResult.dts.pipe(gulp.dest(config.compilerOptions.outDir))
|
39 | ]);
|
40 | });
|
41 |
|
42 | gulp.task("build", gulp.series("clean", gulp.parallel("copy", "compile")));
|