1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-30 11:16:38 -05:00
denoland-deno/std/wasi/snapshot_preview1_test_runner.ts
Casper Beyer c5611636fb
feat(std/wasi): add start method to Context (#8141)
This adds a start method to the Context to make starting a command less
tedious and yield consistent errors.

Manually setting the memory is still valid for more complex scenarios,
just undocumented for the time being.
2020-11-02 18:50:45 +01:00

19 lines
545 B
TypeScript

// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import Context from "./snapshot_preview1.ts";
const options = JSON.parse(Deno.args[0]);
const pathname = Deno.args[1];
const binary = await Deno.readFile(pathname);
const module = await WebAssembly.compile(binary);
const context = new Context({
env: options.env,
args: [pathname].concat(options.args),
preopens: options.preopens,
});
const instance = new WebAssembly.Instance(module, {
"wasi_snapshot_preview1": context.exports,
});
context.start(instance);