diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-30 21:34:41 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-12 13:22:02 -0300 |
| commit | 2348776791e9dd17afeb12a06ba42a4a71917bcf (patch) | |
| tree | 780c4b12b76c8b97a28408dd40944d65f159fdc7 /tools/wasi_run.mjs | |
| parent | 590ba7b9b579b97e34b51ab7e3460ebc85713343 (diff) | |
| download | sketchbook-2348776791e9dd17afeb12a06ba42a4a71917bcf.tar.gz sketchbook-2348776791e9dd17afeb12a06ba42a4a71917bcf.zip | |
sketchbook: a drawing layer on top, host fixes for replay and migration
Diffstat (limited to 'tools/wasi_run.mjs')
| -rw-r--r-- | tools/wasi_run.mjs | 9 |
1 files changed, 9 insertions, 0 deletions
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())); |
