-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.ts
44 lines (38 loc) · 1.2 KB
/
index.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
#!/usr/bin/env node
import { default as program } from "commander";
import { readJSONSync, lstatSync } from "fs-extra";
import { resolve } from "path";
import { build, clean, debug } from "./cli";
const packageJSON = readJSONSync(resolve(__dirname, "../../package.json"));
program.version(packageJSON.version);
program
.option('-w, --watch', "watch mode")
program
.command("build <dir>")
.description("build ts type")
.action((dir: string) => {
const path = resolve(process.cwd(), dir);
if (lstatSync(path).isDirectory()) {
const options = program.opts();
build(path, { watch: options.watch });
}
});
program
.command("clean <dir>")
.description("clean ts type")
.action((dir: string) => {
const path = resolve(process.cwd(), dir);
if (lstatSync(path).isDirectory()) {
clean(path);
}
});
program
.command("debug <file>")
.description("debug ts type")
.action((file: string) => {
const path = resolve(process.cwd(), file);
if (!lstatSync(path).isDirectory()) {
debug(path);
}
});
program.parse(process.argv);