| 295 | * Create a mock file system executor for testing |
| 296 | */ |
| 297 | export function createMockFileSystemExecutor( |
| 298 | overrides?: Partial<FileSystemExecutor>, |
| 299 | ): FileSystemExecutor { |
| 300 | const mockWriteStream = ((): WriteStream => { |
| 301 | const emitter = new EventEmitter(); |
| 302 | const stream = Object.assign(emitter, { |
| 303 | destroyed: false, |
| 304 | write: () => true, |
| 305 | end: () => { |
| 306 | stream.destroyed = true; |
| 307 | emitter.emit('close'); |
| 308 | }, |
| 309 | }) as unknown as WriteStream; |
| 310 | return stream; |
| 311 | })(); |
| 312 | |
| 313 | return { |
| 314 | mkdir: async (): Promise<void> => {}, |
| 315 | readFile: async (): Promise<string> => 'mock file content', |
| 316 | writeFile: async (): Promise<void> => {}, |
| 317 | createWriteStream: () => mockWriteStream, |
| 318 | cp: async (): Promise<void> => {}, |
| 319 | readdir: async (): Promise<unknown[]> => [], |
| 320 | rm: async (): Promise<void> => {}, |
| 321 | existsSync: (): boolean => false, |
| 322 | stat: async (): Promise<{ isDirectory(): boolean; mtimeMs: number }> => ({ |
| 323 | isDirectory: (): boolean => true, |
| 324 | mtimeMs: Date.now(), |
| 325 | }), |
| 326 | mkdtemp: async (): Promise<string> => '/tmp/mock-temp-123456', |
| 327 | tmpdir: (): string => '/tmp', |
| 328 | ...overrides, |
| 329 | }; |
| 330 | } |
| 331 | |
| 332 | /** |
| 333 | * Create a no-op file system executor that throws an error if called |