Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(web-host): prepareFilesystem - split template
  • Loading branch information
topheman committed Aug 19, 2025
commit 3ccf8672cd77fd32ac377f45e1a71186d9bbd99a
24 changes: 13 additions & 11 deletions packages/web-host/clis/prepareFilesystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ function assertPathIsString(path: string): asserts path is string {
}
}

function template(data: VirtualFs): string {
return `// THIS FILE IS GENERATED BY THE prepareVirtualFs COMMAND, DO NOT EDIT IT MANUALLY

// It is meant to be used for mounting a virtual filesystem in the browser
// interacting with @bytecodealliance/preview2-shim/filesystem , the shim for wasi:filesystem
//
// The \`fs\` calls like \`read\`, \`readDir\` ... in rust or other languages will be redirected to this virtual filesystem
// and will interact as if the filesystem was a real one.

export function makeVirtualFs() { return ${JSON.stringify(data, null, 2)}; }`;
}

function run() {
program
.description("Prepare wasm files for the web host")
Expand All @@ -65,17 +77,7 @@ function run() {
if (options.format === "json") {
console.log(JSON.stringify(virtualFs, null, 2));
} else if (options.format === "ts") {
console.log(
`// THIS FILE IS GENERATED BY THE prepareVirtualFs COMMAND, DO NOT EDIT IT MANUALLY

// It is meant to be used for mounting a virtual filesystem in the browser
// interacting with @bytecodealliance/preview2-shim/filesystem , the shim for wasi:filesystem
//
// The \`fs\` calls like \`read\`, \`readDir\` ... in rust or other languages will be redirected to this virtual filesystem
// and will interact as if the filesystem was a real one.

export function makeVirtualFs() { return ${JSON.stringify(virtualFs, null, 2)}; }`,
);
console.log(template(virtualFs));
}
});

Expand Down