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

Function getShellConfigFile

packages/arctic/src/cli/cmd/uninstall.ts:240–282  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

238}
239
240async function getShellConfigFile(): Promise<string | null> {
241 const shell = path.basename(process.env.SHELL || "bash")
242 const home = os.homedir()
243 const xdgConfig = process.env.XDG_CONFIG_HOME || path.join(home, ".config")
244
245 const configFiles: Record<string, string[]> = {
246 fish: [path.join(xdgConfig, "fish", "config.fish")],
247 zsh: [
248 path.join(home, ".zshrc"),
249 path.join(home, ".zshenv"),
250 path.join(xdgConfig, "zsh", ".zshrc"),
251 path.join(xdgConfig, "zsh", ".zshenv"),
252 ],
253 bash: [
254 path.join(home, ".bashrc"),
255 path.join(home, ".bash_profile"),
256 path.join(home, ".profile"),
257 path.join(xdgConfig, "bash", ".bashrc"),
258 path.join(xdgConfig, "bash", ".bash_profile"),
259 ],
260 ash: [path.join(home, ".ashrc"), path.join(home, ".profile")],
261 sh: [path.join(home, ".profile")],
262 }
263
264 const candidates = configFiles[shell] || configFiles.bash
265
266 for (const file of candidates) {
267 const exists = await fs
268 .access(file)
269 .then(() => true)
270 .catch(() => false)
271 if (!exists) continue
272
273 const content = await Bun.file(file)
274 .text()
275 .catch(() => "")
276 if (content.includes("# arctic") || content.includes(".arctic/bin")) {
277 return file
278 }
279 }
280
281 return null
282}
283
284async function cleanShellConfig(file: string) {
285 const content = await Bun.file(file).text()

Callers 1

collectRemovalTargetsFunction · 0.85

Calls 1

textMethod · 0.65

Tested by

no test coverage detected