-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.ts
61 lines (53 loc) · 1.48 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
import * as del from "del";
import * as gulp from "gulp";
import * as gutil from "gulp-util";
import * as jsonfile from "jsonfile";
import * as sourcemaps from "gulp-sourcemaps";
import * as ts from "gulp-typescript";
const tslint = require("gulp-tslint");
const prettier = require("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("prettier", () => {
const cfg = jsonfile.readFileSync("./.prettierrc", { throws: false });
if (cfg === null) {
throw new gutil.PluginError({
plugin: "prettier",
message: "missing or deformed .prettierrc"
});
}
return gulp
.src(src)
.pipe(prettier(cfg, { filter: true }) as any)
.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/**/*.ttf"], { base: "." }).pipe(gulp.dest("dist"));
});
gulp.task("build", gulp.series("clean", "typescript", "copyTestFile"));