Build a fake handle that records writes/execs and tracks existing paths.
(execResult: ExecResult)
| 40 | |
| 41 | /** Build a fake handle that records writes/execs and tracks existing paths. */ |
| 42 | function makeFakeHandle(execResult: ExecResult): FakeHandle { |
| 43 | const writes = new Map<string, string>() |
| 44 | const execs: Array<RecordedExec> = [] |
| 45 | const existing = new Set<string>() |
| 46 | const dirs = new Set<string>() |
| 47 | |
| 48 | const handle = { |
| 49 | fs: { |
| 50 | write: (path: string, data: string | Uint8Array) => { |
| 51 | writes.set(path, typeof data === 'string' ? data : '') |
| 52 | existing.add(path) |
| 53 | return Promise.resolve() |
| 54 | }, |
| 55 | exists: (path: string) => Promise.resolve(existing.has(path)), |
| 56 | mkdir: (path: string) => { |
| 57 | dirs.add(path) |
| 58 | return Promise.resolve() |
| 59 | }, |
| 60 | }, |
| 61 | process: { |
| 62 | exec: (command: string, options?: { cwd?: string }) => { |
| 63 | execs.push({ command, cwd: options?.cwd }) |
| 64 | return Promise.resolve(execResult) |
| 65 | }, |
| 66 | }, |
| 67 | } as unknown as SandboxHandle |
| 68 | |
| 69 | return { handle, writes, execs, existing } |
| 70 | } |
| 71 | |
| 72 | const ROOT = '/workspace' |
| 73 | const MARKER = `${ROOT}/.tanstack-projected-abc123` |
no test coverage detected