MCPcopy Index your code
hub / github.com/anomalyco/opencode / cleanShellConfig

Function cleanShellConfig

packages/opencode/src/cli/cmd/uninstall.ts:277–315  ·  view source on GitHub ↗
(file: string)

Source from the content-addressed store, hash-verified

275}
276
277async 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
317async function getDirectorySize(dir: string): Promise<number> {
318 let total = 0

Callers 1

executeUninstallFunction · 0.85

Calls 2

pushMethod · 0.80
writeMethod · 0.80

Tested by

no test coverage detected