forked from tutao/tutanota
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake.js
45 lines (40 loc) · 1.25 KB
/
make.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
import options from "commander"
import {runDevBuild} from "./buildSrc/DevBuild.js"
import {spawn} from "child_process"
options
.usage('[options] [test|prod|local|host <url>], "local" is default')
.arguments('[stage] [host]')
.option('-c, --clean', 'Clean build directory')
.option('-w, --watch', 'Watch build dir and rebuild if necessary')
.option('-d, --desktop', 'Assemble & start desktop client')
.option('-s, --serve', 'Start a local server to serve the website')
.action(async (stage, host, options) => {
if (!["test", "prod", "local", "host", undefined].includes(stage)
|| (stage !== "host" && host)
|| (stage === "host" && !host)) {
options.outputHelp()
process.exit(1)
}
const {clean, watch, serve, desktop} = options
try {
await runDevBuild({
stage: stage ?? "local",
host,
clean,
watch,
serve,
desktop
})
if (desktop) {
// we don't want to quit here because we want to keep piping output to our stdout.
spawn("./start-desktop.sh", {stdio: "inherit"})
} else if (!watch) {
// Don't wait for spawned child processes to exit (because they never will)
process.exit(0)
}
} catch (e) {
console.error("Build failed:", e)
process.exit(1)
}
})
options.parseAsync(process.argv)