(file: string)
| 275 | } |
| 276 | |
| 277 | async function cleanShellConfig(file: string) { |
| 278 | const content = await Filesystem.readText(file) |
| 279 | const lines = content.split("\n") |
| 280 | |
| 281 | const filtered: string[] = [] |
| 282 | let skip = false |
| 283 | |
| 284 | for (const line of lines) { |
| 285 | const trimmed = line.trim() |
| 286 | |
| 287 | if (trimmed === "# opencode") { |
| 288 | skip = true |
| 289 | continue |
| 290 | } |
| 291 | |
| 292 | if (skip) { |
| 293 | skip = false |
| 294 | if (trimmed.includes(".opencode/bin") || trimmed.includes("fish_add_path")) { |
| 295 | continue |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | if ( |
| 300 | (trimmed.startsWith("export PATH=") && trimmed.includes(".opencode/bin")) || |
| 301 | (trimmed.startsWith("fish_add_path") && trimmed.includes(".opencode")) |
| 302 | ) { |
| 303 | continue |
| 304 | } |
| 305 | |
| 306 | filtered.push(line) |
| 307 | } |
| 308 | |
| 309 | while (filtered.length > 0 && filtered[filtered.length - 1].trim() === "") { |
| 310 | filtered.pop() |
| 311 | } |
| 312 | |
| 313 | const output = filtered.join("\n") + "\n" |
| 314 | await Filesystem.write(file, output) |
| 315 | } |
| 316 | |
| 317 | async function getDirectorySize(dir: string): Promise<number> { |
| 318 | let total = 0 |
no test coverage detected