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 = () => {
62
62
63
63
export const DefaultRubyVM = async (
64
64
rubyModule : WebAssembly . Module ,
65
- options : { consolePrint : boolean } = { consolePrint : true } ,
65
+ options : {
66
+ consolePrint ?: boolean ;
67
+ env ?: Record < string , string > | undefined ;
68
+ } ,
66
69
) : Promise < {
67
70
vm : RubyVM ;
68
71
wasi : WASI ;
69
72
instance : WebAssembly . Instance ;
70
73
} > => {
71
74
await init ( ) ;
72
75
73
- const wasi = new WASI ( { } ) ;
76
+ const wasi = new WASI ( { env : options . env } ) ;
74
77
const vm = new RubyVM ( ) ;
75
78
76
79
const imports = wasi . getImports ( rubyModule ) as WebAssembly . Imports ;
77
80
vm . addToImports ( imports ) ;
78
- const printer = options . consolePrint ? consolePrinter ( ) : undefined ;
81
+ const printer = ( options . consolePrint ?? true ) ? consolePrinter ( ) : undefined ;
79
82
printer ?. addToImports ( imports ) ;
80
83
81
84
const instance = await WebAssembly . instantiate ( rubyModule , imports ) ;
Original file line number Diff line number Diff line change 1
1
import { WASI } from "wasi" ;
2
2
import { RubyVM } from "./index" ;
3
3
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 } ) ;
6
9
const vm = new RubyVM ( ) ;
7
10
const imports = {
8
11
wasi_snapshot_preview1 : wasi . wasiImport ,
You can’t perform that action at this time.
0 commit comments