generated from Himenon/template-js
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathwatch.ts
39 lines (32 loc) · 1.04 KB
/
watch.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
import * as path from "path";
import * as chokidar from "chokidar";
import { shell } from "./tools/shell";
const cwd = path.join(__dirname, "../");
process.on("unhandledRejection", reason => {
console.log(reason);
});
const main = async () => {
console.log((await shell("pnpm build", cwd)).stdout);
console.log((await shell("pnpm run test:code:gen", cwd)).stdout);
chokidar.watch("./src", { ignored: ["src/meta.ts"] }).on("change", async path => {
console.log(`Watch Change file ... ${path}`);
try {
console.log((await shell("pnpm build", cwd)).stdout);
console.log((await shell("pnpm run test:code:gen", cwd)).stdout);
} catch (error) {
console.error("Failed");
}
});
chokidar.watch("./test", { ignored: [/code/] }).on("change", async path => {
console.log(`Watch Change file ... ${path}`);
try {
console.log((await shell("pnpm run test:code:gen", cwd)).stdout);
} catch (error) {
console.error("Failed");
}
});
};
main().catch(error => {
console.error(error);
process.exit(1);
});