-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.ts
68 lines (59 loc) · 1.58 KB
/
gulpfile.ts
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
import del from "del";
import gulp from "gulp";
import jsonfile from "jsonfile";
import sourcemaps from "gulp-sourcemaps";
import ts from "gulp-typescript";
import PluginError from "plugin-error";
import tslint from "gulp-tslint";
import prettier from "gulp-prettier-plugin";
const src = ["./src/**/*.ts", "./test/**/*.ts"];
const tsProject = ts.createProject("tsconfig.json");
gulp.task("typescript", () => {
return gulp
.src(src, { base: "." })
.pipe(sourcemaps.init())
.pipe(tsProject())
.pipe(sourcemaps.write(".", { includeContent: false, sourceRoot: __dirname }))
.pipe(gulp.dest("dist"));
});
gulp.task("copyFiles", () => {
return gulp.src(["src/**/*.png", "src/**/*.json"]).pipe(gulp.dest("dist"));
});
gulp.task("prettier", () => {
const cfg = jsonfile.readFileSync("./.prettierrc", { throws: false });
if (cfg === null) {
throw new PluginError({
plugin: "prettier",
message: "missing or deformed .prettierrc"
});
}
return (
gulp
.src(src)
// @ts-ignore
.pipe(prettier(cfg, { filter: true }))
.pipe(gulp.dest((file: any) => file.base))
);
});
gulp.task("tslint", () =>
gulp
.src(src)
.pipe(
tslint({
formatter: "stylish"
})
)
.pipe(
tslint.report({
allowWarnings: true,
summarizeFailureOutput: true
})
)
);
gulp.task("clean", () => {
return del("dist/*");
});
gulp.task("copyTestFile", () => {
return gulp.src(["test/**/*.class"], { base: "." }).pipe(gulp.dest("dist"));
});
gulp.task("build", gulp.series("clean", "typescript", "copyTestFile"));