tutanota/make.js

46 lines
1.3 KiB
JavaScript
Raw Normal View History

2022-04-28 14:36:24 +02:00
import {program, Argument} 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
2022-04-28 14:36:24 +02:00
await program
.usage('[options] [test|prod|local|host <url>]')
.addArgument(new Argument("stage")
.choices(["test", "prod", "local", "host"])
.default("local")
.argOptional())
.addArgument(new Argument("host").argOptional())
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) => {
2022-04-28 14:36:24 +02:00
if (stage === "host" && host == null || stage !== "host" && host != null) {
program.outputHelp()
2018-12-21 13:29:35 +01:00
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
}
})
2022-04-28 14:36:24 +02:00
.parseAsync(process.argv)