Skip to content

Commit c92fc03

Browse files
committed
fix: fix asc compilation for the tests
- Use stdout/stderr and check the returned error - use outFile instead of binaryFile - remove wasm file if it exists
1 parent 1425863 commit c92fc03

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

test/test-runner.mjs

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import fs from "fs/promises";
2+
import fsSync from "fs";
23
import { dirname, join } from "path";
34
import { createRequire } from "module";
45

@@ -43,18 +44,32 @@ async function compileAllAsc() {
4344
Object.assign(config, m);
4445
} catch (e) {}
4546
console.log(`Compiling ${ascFile}...`);
47+
48+
const wasmFile = ascFile.replace(/\.ts$/, ".wasm");
49+
if (fsSync.existsSync(wasmFile)) {
50+
await fs.unlink(wasmFile);
51+
}
52+
4653
const params = [
4754
"--runtime",
4855
"stub",
4956
"--exportRuntime",
5057
"--transform",
5158
transformFile,
52-
"--binaryFile",
59+
"--outFile",
5360
ascFile.replace(/\.ts$/, ".wasm"),
5461
ascFile
5562
];
5663
config.mangleCompilerParams(params);
57-
await asc.main(params);
64+
const result = await asc.main(params, {
65+
stderr: process.stderr,
66+
stdout: process.stdout
67+
});
68+
69+
if (result.error !== null) {
70+
console.error(`Failed to compile ${ascFile}`);
71+
process.exit(1);
72+
}
5873
}
5974
}
6075

0 commit comments

Comments
 (0)