Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
bokuweb committed Oct 2, 2024
1 parent 47312c3 commit babdca5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions js/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export type CompareOutput = {
diffDir: string,
};

console.log(workerData.argv, 'arg')

const wasi = new WASI({
version: 'preview1',
args: workerData.argv,
Expand Down
4 changes: 2 additions & 2 deletions js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const run = (argv: string[]): EventEmitter => {
const workers = [worker];

const spawn = (startArg: number, threadId: Int32Array, memory: WebAssembly.Memory) => {
const worker = new Worker(join(dir(), `./worker.${resolveExtention()}`));
const worker = new Worker(join(dir(), `./worker.${resolveExtention()}`), { workerData: { argv } });

workers.push(worker);

Expand Down Expand Up @@ -111,7 +111,7 @@ export const compare = (input: CompareInput): EventEmitter => {
actualDir,
expectedDir,
diffDir,
...Object.entries(rest).flatMap(([k, v]) => (v == null ? [] : [`--${k}`, String(v)])),
...Object.entries(rest).flatMap(([k, v]) => (v == null || v === '' ? [] : [`--${k}`, String(v)])),
];
return run(args);
};
2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "reg-cli",
"version": "0.0.0-experimental-wasm10",
"version": "0.0.0-experimental-wasm13",
"description": "",
"type": "module",
"start": "node ./dist/cli.mjs",
Expand Down
6 changes: 4 additions & 2 deletions js/worker.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { parentPort } from 'node:worker_threads';
import { parentPort, workerData } from 'node:worker_threads';
import fs from 'node:fs';
import { WASI, type IFs } from '@tybys/wasm-util';
import { argv, env } from 'node:process';
import { readWasm, resolveExtention } from './utils';
// https://github.com/toyobayashi/emnapi/blob/5ab92c706c7cd4a0a30759e58f26eedfb0ded591/packages/wasi-threads/src/wasi-threads.ts#L288-L335
import { createInstanceProxy } from './proxy';

console.log(workerData.argv, 'arg')

const wasi = new WASI({
version: 'preview1',
args: argv,
args: workerData.argv,
env: env as Record<string, string>,
returnOnExit: true,
preopens: { './': './' },
Expand Down

0 comments on commit babdca5

Please sign in to comment.