-
Notifications
You must be signed in to change notification settings - Fork 0
/
mod.ts
69 lines (63 loc) · 1.53 KB
/
mod.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env deno
const args = Array.from(Deno.args);
if (args[0] === "init") {
args.shift();
await run("run", "-A", "https://lume.land/init.ts", ...args);
} else if (args[0] === "upgrade-cli") {
await run(
"install",
"--allow-run",
"--allow-env",
"--allow-read",
"--name",
"lume",
"--force",
"--reload",
"--global",
"https://deno.land/x/lume_cli/mod.ts",
);
} else if (args[0] === "serve" || args[0] === "build") {
await run("task", ...args);
} else {
await run("task", "lume", ...args);
}
async function run(...args: string[]) {
if (hasFlag("--drafts", args)) {
Deno.env.set("LUME_DRAFTS", "true");
}
if (hasFlag("--debug", args)) {
Deno.env.set("LUME_LOGS", "DEBUG");
}
if (hasFlag("--info", args)) {
Deno.env.set("LUME_LOGS", "INFO");
}
if (hasFlag("--warning", args)) {
Deno.env.set("LUME_LOGS", "WARN");
}
if (hasFlag("--warn", args)) {
Deno.env.set("LUME_LOGS", "WARN");
}
if (hasFlag("--error", args)) {
Deno.env.set("LUME_LOGS", "ERROR");
}
if (hasFlag("--critical", args)) {
Deno.env.set("LUME_LOGS", "CRITICAL");
}
if (hasFlag("--no-cache", args)) {
Deno.env.set("LUME_NOCACHE", "true");
}
const command = new Deno.Command(Deno.execPath(), {
args: args,
stdin: "inherit",
stdout: "inherit",
stderr: "inherit",
});
await command.output();
}
function hasFlag(flag: string, args: string[]): boolean {
if (args.includes(flag)) {
args.splice(args.indexOf(flag), 1);
return true;
}
return false;
}