forked from murphysecurity/murphysec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgobuild.ts
31 lines (29 loc) · 892 Bytes
/
gobuild.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
const targets: [string, string][] = [
["linux", "amd64"],
["darwin", "amd64"],
["windows", "amd64"],
];
const isSaaS = Deno.args.indexOf("saas") > -1;
const bn = isSaaS ? "murphysec-saas" : "murphysec";
const tags = [!isSaaS ? "pro" : ""].filter((it) => it);
const opts = targets.map((it) => ({
cmd: [
"go",
"build",
tags.length > 0 ? ["-tags", ...tags] : [],
"-o",
`out/${bn}-${it[0]}-${it[1]}${it[0] === "windows" ? ".exe" : ""}`,
".",
].flat().filter((it) => it),
env: {GOOS: it[0], GOARCH: it[1]},
stdin: "null" as "null",
}));
console.log(opts);
const process = opts.map((it) => Deno.run(it).status());
const status = await Promise.all(process);
if (status.every((it) => it.success && it.code === 0)) {
console.log("编译成功");
} else {
console.error("编译失败", status);
Deno.exit(-1);
}