From 2348776791e9dd17afeb12a06ba42a4a71917bcf Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 30 Oct 2026 21:34:41 -0300 Subject: sketchbook: a drawing layer on top, host fixes for replay and migration --- tools/wasi_run.mjs | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 tools/wasi_run.mjs (limited to 'tools/wasi_run.mjs') diff --git a/tools/wasi_run.mjs b/tools/wasi_run.mjs new file mode 100644 index 0000000..ab5d95a --- /dev/null +++ b/tools/wasi_run.mjs @@ -0,0 +1,9 @@ +// Runs a wasm32-wasi program (a Zig test binary) under Node's WASI, with +// the rest of the arguments as its own; exits with its exit code. +// usage: node tools/wasi_run.mjs program.wasm [args...] +import {readFile} from 'node:fs/promises'; +import {WASI} from 'node:wasi'; + +const wasi = new WASI({version: 'preview1', args: process.argv.slice(2), env: {}, returnOnExit: true}); +const module = await WebAssembly.compile(await readFile(process.argv[2])); +process.exitCode = wasi.start(await WebAssembly.instantiate(module, wasi.getImportObject())); -- cgit v1.3