Skip to content

Commit 59f9127

Browse files
Update bjorn3/browser_wasi_shim to 0.3.0
1 parent 0606ae6 commit 59f9127

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

packages/npm-packages/ruby-wasm-wasi/src/browser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const DefaultRubyVM = async (
2222
new OpenFile(new File([])),
2323
new OpenFile(new File([])),
2424
new OpenFile(new File([])),
25-
new PreopenDirectory("/", {}),
25+
new PreopenDirectory("/", new Map()),
2626
];
2727
const wasi = new WASI(args, env, fds, { debug: false });
2828
const vm = new RubyVM();

packages/npm-packages/ruby-wasm-wasi/tools/run-test-unit.mjs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,22 @@ const instantiateWasmerWasi = async (rootTestFile) => {
6868
return files.flat();
6969
};
7070

71-
const __root__ = new browserWasi.Directory({});
71+
const __root__ = new browserWasi.Directory(new Map());
7272
const writeMemFs = (guestPath, contents) => {
7373
const dirname = path.dirname(guestPath);
7474
const parts = dirname.split('/');
7575
let current = __root__;
7676
for (let i = 1; i < parts.length; i++) {
77-
const dir = current.create_entry_for_path(parts[i], /* is_dir */ true);
78-
current = dir;
77+
const existing = current.contents.get(parts[i]);
78+
if (existing) {
79+
current = existing;
80+
} else {
81+
const { entry: created } = current.create_entry_for_path(parts[i], /* is_dir */ true);
82+
current = created;
83+
}
7984
}
8085
const basename = path.basename(guestPath);
81-
const file = current.create_entry_for_path(basename, /* is_dir */ false)
86+
const { entry: file } = current.create_entry_for_path(basename, /* is_dir */ false)
8287
file.data = contents;
8388
};
8489
const loadToMemFs = async (guestPath, hostPath) => {

0 commit comments

Comments
 (0)