| 47 | const worker = path.join(import.meta.dir, "../fixture/effect-flock-worker.ts") |
| 48 | |
| 49 | function run(msg: Msg) { |
| 50 | return new Promise<{ code: number; stdout: Buffer; stderr: Buffer }>((resolve) => { |
| 51 | const proc = spawn(process.execPath, [worker, JSON.stringify(msg)], { cwd: root }) |
| 52 | const stdout: Buffer[] = [] |
| 53 | const stderr: Buffer[] = [] |
| 54 | proc.stdout?.on("data", (data) => stdout.push(Buffer.from(data))) |
| 55 | proc.stderr?.on("data", (data) => stderr.push(Buffer.from(data))) |
| 56 | proc.on("close", (code) => { |
| 57 | resolve({ code: code ?? 1, stdout: Buffer.concat(stdout), stderr: Buffer.concat(stderr) }) |
| 58 | }) |
| 59 | }) |
| 60 | } |
| 61 | |
| 62 | function spawnWorker(msg: Msg) { |
| 63 | return spawn(process.execPath, [worker, JSON.stringify(msg)], { |