Map proc_exit to process exit on Node.js

This commit is contained in:
Yuta Saito 2024-04-17 17:53:12 +00:00
parent 5894a86bac
commit 662d29d305
3 changed files with 26 additions and 13 deletions

File diff suppressed because one or more lines are too long

View File

@ -63,9 +63,14 @@ export const WasmRunner = (rawOptions: Options | false, SwiftRuntime: SwiftRunti
}
if (extraWasmImports) {
// Shallow clone
for (const key in extraWasmImports) {
importObject[key] = extraWasmImports[key];
for (const moduleName in extraWasmImports) {
// importObject[moduleName] = extraWasmImports[moduleName];
if (!importObject[moduleName]) {
importObject[moduleName] = {};
}
for (const entry in extraWasmImports[moduleName]) {
importObject[moduleName][entry] = extraWasmImports[moduleName][entry];
}
}
}

View File

@ -46,7 +46,15 @@ const startWasiTask = async () => {
const wasmRunner = WasmRunner({ args: testArgs }, runtimeConstructor);
await wasmRunner.run(wasmBytes);
await wasmRunner.run(wasmBytes, {
"wasi_snapshot_preview1": {
// @bjorn3/browser_wasi_shim raises an exception when
// the process exits, but we just want to exit the process itself.
proc_exit: (code: number) => {
process.exit(code);
},
}
});
};
startWasiTask().catch((e) => {