-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.js
executable file
·56 lines (45 loc) · 1.02 KB
/
cli.js
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
#!/usr/bin/env node
import fs from "node:fs/promises";
switch (process.argv[2]) {
case "start":
await start();
break;
case "build":
await build();
break;
case "dev":
await dev();
break;
case "clean":
await clean();
break;
case "help":
console.info(`Usage: jeasx [start|build|dev|clean|help]`);
break;
default:
console.info(
`❌ Error: Unknown command '${process.argv[2]}'.\nUse 'jeasx help' for options.`
);
process.exit(1);
}
async function start() {
await import("./server.js");
}
async function build() {
await import("./esbuild.config.js");
}
async function dev() {
process.env.NODE_ENV = "development";
process.setSourceMapsEnabled(true);
// Bun: https://bun.sh/docs/runtime/nodejs-apis#process
if (process.sourceMapsEnabled === undefined) {
// @ts-ignore
process.sourceMapsEnabled = true;
}
await build();
await start();
}
async function clean() {
await fs.rm("dist", { recursive: true, force: true, maxRetries: 3 });
}
export {};