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

Function executeUninstall

packages/arctic/src/cli/cmd/uninstall.ts:141–238  ·  view source on GitHub ↗
(method: Installation.Method, targets: RemovalTargets)

Source from the content-addressed store, hash-verified

139}
140
141async function executeUninstall(method: Installation.Method, targets: RemovalTargets) {
142 const spinner = prompts.spinner()
143 const errors: string[] = []
144
145 for (const dir of targets.directories) {
146 if (dir.keep) {
147 prompts.log.step(`Skipping ${dir.label} (--keep-${dir.label.toLowerCase()})`)
148 continue
149 }
150
151 const exists = await fs
152 .access(dir.path)
153 .then(() => true)
154 .catch(() => false)
155 if (!exists) continue
156
157 spinner.start(`Removing ${dir.label}...`)
158 const err = await fs.rm(dir.path, { recursive: true, force: true }).catch((e) => e)
159 if (err) {
160 spinner.stop(`Failed to remove ${dir.label}`, 1)
161 errors.push(`${dir.label}: ${err.message}`)
162 continue
163 }
164 spinner.stop(`Removed ${dir.label}`)
165 }
166
167 if (targets.shellConfig) {
168 spinner.start("Cleaning shell config...")
169 const err = await cleanShellConfig(targets.shellConfig).catch((e) => e)
170 if (err) {
171 spinner.stop("Failed to clean shell config", 1)
172 errors.push(`Shell config: ${err.message}`)
173 } else {
174 spinner.stop("Cleaned shell config")
175 }
176 }
177
178 if (method !== "curl" && method !== "unknown") {
179 const cmds: Record<string, string[]> = {
180 npm: ["npm", "uninstall", "-g", "@arctic-cli/arctic"],
181 pnpm: ["pnpm", "uninstall", "-g", "@arctic-cli/arctic"],
182 bun: ["bun", "remove", "-g", "@arctic-cli/arctic"],
183 yarn: ["yarn", "global", "remove", "@arctic-cli/arctic"],
184 brew: ["brew", "uninstall", "arctic"],
185 }
186
187 const cmd = cmds[method]
188 if (cmd) {
189 spinner.start(`Running ${cmd.join(" ")}...`)
190 const result = await $`${cmd}`.quiet().nothrow()
191 if (result.exitCode !== 0) {
192 spinner.stop(`Package manager uninstall failed`, 1)
193 prompts.log.warn(`You may need to run manually: ${cmd.join(" ")}`)
194 errors.push(`Package manager: exit code ${result.exitCode}`)
195 } else {
196 spinner.stop("Package removed")
197 }
198 }

Callers 1

uninstall.tsFile · 0.85

Calls 7

cleanShellConfigFunction · 0.85
stopMethod · 0.80
pushMethod · 0.80
quietMethod · 0.80
nothrowMethod · 0.65
startMethod · 0.45
messageMethod · 0.45

Tested by

no test coverage detected