tutanota/make.js

45 lines
1.2 KiB
JavaScript
Raw Normal View History

2019-09-13 13:49:11 +02:00
import options from "commander"
import {runDevBuild} from "./buildSrc/DevBuild.js"
2019-09-13 13:49:11 +02:00
import {spawn} from "child_process"
2017-08-15 13:54:22 +02:00
2018-10-02 16:02:55 +02:00
options
2018-12-21 13:29:35 +01:00
.usage('[options] [test|prod|local|host <url>], "local" is default')
.arguments('[stage] [host]')
2018-10-02 16:02:55 +02:00
.option('-c, --clean', 'Clean build directory')
2018-10-04 10:28:39 +02:00
.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) => {
2018-12-21 13:29:35 +01:00
if (!["test", "prod", "local", "host", undefined].includes(stage)
|| (stage !== "host" && host)
|| (stage === "host" && !host)) {
options.outputHelp()
process.exit(1)
}
2021-07-28 12:20:36 +02:00
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)
2021-07-28 12:20:36 +02:00
}
})
2021-07-28 12:20:36 +02:00
options.parseAsync(process.argv)