(path: string, content: string)
| 53 | |
| 54 | // File operations |
| 55 | create(path: string, content: string): MockFile { |
| 56 | const normalizedPath = this.normalizePath(path); |
| 57 | |
| 58 | if (this.files.has(normalizedPath)) { |
| 59 | throw new Error(`File already exists: ${normalizedPath}`); |
| 60 | } |
| 61 | |
| 62 | this.ensureFolderExists(this.getParentPath(normalizedPath)); |
| 63 | |
| 64 | const file: MockFile = { |
| 65 | path: normalizedPath, |
| 66 | name: this.getFileName(normalizedPath), |
| 67 | basename: this.getBaseName(normalizedPath), |
| 68 | extension: this.getExtension(normalizedPath), |
| 69 | content, |
| 70 | stat: { |
| 71 | ctime: Date.now(), |
| 72 | mtime: Date.now(), |
| 73 | size: content.length, |
| 74 | }, |
| 75 | }; |
| 76 | |
| 77 | this.files.set(normalizedPath, file); |
| 78 | this.emitter.emit('create', file); |
| 79 | return file; |
| 80 | } |
| 81 | |
| 82 | modify(file: MockFile, content: string): void { |
| 83 | file.content = content; |
nothing calls this directly
no test coverage detected