File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed
packages/npm-packages/ruby-wasm-wasi/src Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -62,20 +62,23 @@ const consolePrinter = () => {
6262
6363export const DefaultRubyVM = async (
6464 rubyModule : WebAssembly . Module ,
65- options : { consolePrint : boolean } = { consolePrint : true } ,
65+ options : {
66+ consolePrint ?: boolean ;
67+ env ?: Record < string , string > | undefined ;
68+ } = { } ,
6669) : Promise < {
6770 vm : RubyVM ;
6871 wasi : WASI ;
6972 instance : WebAssembly . Instance ;
7073} > => {
7174 await init ( ) ;
7275
73- const wasi = new WASI ( { } ) ;
76+ const wasi = new WASI ( { env : options . env } ) ;
7477 const vm = new RubyVM ( ) ;
7578
7679 const imports = wasi . getImports ( rubyModule ) as WebAssembly . Imports ;
7780 vm . addToImports ( imports ) ;
78- const printer = options . consolePrint ? consolePrinter ( ) : undefined ;
81+ const printer = ( options . consolePrint ?? true ) ? consolePrinter ( ) : undefined ;
7982 printer ?. addToImports ( imports ) ;
8083
8184 const instance = await WebAssembly . instantiate ( rubyModule , imports ) ;
Original file line number Diff line number Diff line change 11import { WASI } from "wasi" ;
22import { RubyVM } from "./index" ;
33
4- export const DefaultRubyVM = async ( rubyModule : WebAssembly . Module ) => {
5- const wasi = new WASI ( ) ;
4+ export const DefaultRubyVM = async (
5+ rubyModule : WebAssembly . Module ,
6+ options : { env ?: Record < string , string > | undefined } = { } ,
7+ ) => {
8+ const wasi = new WASI ( { env : options . env } ) ;
69 const vm = new RubyVM ( ) ;
710 const imports = {
811 wasi_snapshot_preview1 : wasi . wasiImport ,
You can’t perform that action at this time.
0 commit comments