MCPcopy Create free account
hub / github.com/arctic-cli/interface / cleanShellConfig

Function cleanShellConfig

packages/arctic/src/cli/cmd/uninstall.ts:284–322  ·  view source on GitHub ↗
(file: string)

Source from the content-addressed store, hash-verified

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

Callers 1

executeUninstallFunction · 0.85

Calls 2

pushMethod · 0.80
textMethod · 0.65

Tested by

no test coverage detected