-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
45 lines (41 loc) · 1.04 KB
/
Copy pathindex.ts
File metadata and controls
45 lines (41 loc) · 1.04 KB
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
import { spawn } from "bun";
const command = process.argv[2];
const commands: Record<string, () => void> = {
build: async () => {
const proc = spawn(["bun", "run", "build.ts"], {
stdout: "inherit",
stderr: "inherit",
});
await proc.exited;
},
serve: async () => {
const proc = spawn(["bun", "run", "serve.ts"], {
stdout: "inherit",
stderr: "inherit",
});
await proc.exited;
},
test: async () => {
const proc = spawn(["bun", "test"], {
stdout: "inherit",
stderr: "inherit",
});
await proc.exited;
},
help: () => {
console.log(`
Usage: bun run index.ts <command>
Commands:
build Generate the static site
serve Start the local development server
test Run the test suite
help Show this help message
`);
},
};
const cmd = command && Object.hasOwn(commands, command) ? commands[command] : undefined;
if (cmd) {
cmd();
} else {
commands.help!();
}