-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.ts
More file actions
33 lines (30 loc) · 744 Bytes
/
cli.ts
File metadata and controls
33 lines (30 loc) · 744 Bytes
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
import { cli } from "./src/cli/mod.ts";
if (import.meta.main) {
const devScript = "dev.ts";
if (await fileExists(devScript)) {
// When a dev.ts script exists, run it.
// This prevents version edcb version mismatch.
await runScript(devScript, Deno.args);
} else {
await cli();
}
}
async function runScript(file: string, args: string[]) {
const p = Deno.run({
cmd: ["deno", "run", "-A", "--unstable", file, ...args],
});
const status = await p.status();
p.close();
Deno.exit(status.code);
}
async function fileExists(file: string) {
try {
await Deno.lstat(file);
return true;
} catch (error) {
if (!(error instanceof Deno.errors.NotFound)) {
throw error;
}
}
return false;
}