-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_wasm.ts
51 lines (42 loc) · 1.01 KB
/
build_wasm.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
import { parse } from "@std/toml";
import { resolve } from "@std/path";
const isCheck = Deno.args.some((a) => a === "--check");
const failFast = Deno.args.some((a) => a === "--fail-fast");
const rawCargo = Deno.readTextFileSync("./_wasm/Cargo.toml");
const parsedCargo = parse(rawCargo) as { workspace: { members: string[] } };
let didFail = false;
for (const member of parsedCargo.workspace.members) {
const [folder] = member.split("_");
const outPath = resolve(
folder,
"_wasm",
);
const args: string[] = [
"run",
"-A",
"jsr:@deno/[email protected]",
"--js-ext",
"mjs",
"--sync",
"--project",
member,
"--out",
outPath,
];
if (isCheck) {
args.push("--check");
}
const command = new Deno.Command(Deno.execPath(), {
args: args,
cwd: "./_wasm",
});
const child = command.spawn();
const status = await child.status;
if (!status.success) {
didFail = true;
}
if (failFast && didFail) {
Deno.exit(1);
}
}
Deno.exit(didFail ? 1 : 0);