-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.mjs
37 lines (29 loc) · 1.11 KB
/
gulpfile.mjs
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
import { series, parallel, src, dest, watch } from "gulp";
import { task } from "gulp-execa";
import { readFile } from "node:fs/promises";
import { deleteAsync } from "del";
import zip from "gulp-zip";
const info = JSON.parse(await readFile("src/info.json", "utf8"));
const release_name = `${info.name}_${info.version}`;
const output_dir = `dist/${release_name}/`;
const assets_glob = "src/**/*.{json,png,txt,cfg}";
const build_ts = task(`tstl --outDir ${output_dir}`);
const build_lint = task("eslint src");
export const build_assets = () => {
return src(assets_glob, { encoding: false }).pipe(dest(output_dir));
};
export const clean = async () => {
await deleteAsync(["dist"]);
};
export const build = series(clean, parallel(build_ts, build_assets, build_lint));
export const dev = async () => {
watch(["src/**/*.ts", "tsconfig.json", "package.json"], build_ts);
watch(assets_glob, build_assets);
};
export const compress = () => {
return src("dist/**/*", { encoding: false })
.pipe(zip(`${release_name}.zip`))
.pipe(dest("dist"));
};
export const release = series(build, compress);
export default dev;