| 176 | // --------------------------------------------------------------------------- |
| 177 | |
| 178 | function parseDirectoryListing(basePath: string, text: string): FileEntry[] { |
| 179 | const entries: FileEntry[] = []; |
| 180 | for (const line of text.split("\n")) { |
| 181 | const trimmed = line.trim(); |
| 182 | if (!trimmed) continue; |
| 183 | const isDir = trimmed.endsWith("/"); |
| 184 | const name = isDir ? trimmed.slice(0, -1) : trimmed; |
| 185 | const joinedPath = `${basePath.replace(/\/$/, "")}/${name}`; |
| 186 | entries.push({ name, path: joinedPath, type: isDir ? "directory" : "file" }); |
| 187 | } |
| 188 | return entries; |
| 189 | } |
| 190 | |
| 191 | // Matches: path/to/file.ts:42: some content |
| 192 | const GREP_LINE_RE = /^([^:]+):(\d+):(.*)$/; |