MCPcopy Index your code
hub / github.com/codeaashu/claude-code / cleanupNpmInstallations

Function cleanupNpmInstallations

src/utils/nativeInstaller/installer.ts:1656–1708  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1654}
1655
1656export async function cleanupNpmInstallations(): Promise<{
1657 removed: number
1658 errors: string[]
1659 warnings: string[]
1660}> {
1661 const errors: string[] = []
1662 const warnings: string[] = []
1663 let removed = 0
1664
1665 // Always attempt to remove @anthropic-ai/claude-code
1666 const codePackageResult = await attemptNpmUninstall(
1667 '@anthropic-ai/claude-code',
1668 )
1669 if (codePackageResult.success) {
1670 removed++
1671 if (codePackageResult.warning) {
1672 warnings.push(codePackageResult.warning)
1673 }
1674 } else if (codePackageResult.error) {
1675 errors.push(codePackageResult.error)
1676 }
1677
1678 // Also attempt to remove MACRO.PACKAGE_URL if it's defined and different
1679 if (MACRO.PACKAGE_URL && MACRO.PACKAGE_URL !== '@anthropic-ai/claude-code') {
1680 const macroPackageResult = await attemptNpmUninstall(MACRO.PACKAGE_URL)
1681 if (macroPackageResult.success) {
1682 removed++
1683 if (macroPackageResult.warning) {
1684 warnings.push(macroPackageResult.warning)
1685 }
1686 } else if (macroPackageResult.error) {
1687 errors.push(macroPackageResult.error)
1688 }
1689 }
1690
1691 // Check for local installation at ~/.claude/local
1692 const localInstallDir = join(homedir(), '.claude', 'local')
1693
1694 try {
1695 await rm(localInstallDir, { recursive: true })
1696 removed++
1697 logForDebugging(`Removed local installation at ${localInstallDir}`)
1698 } catch (error) {
1699 if (!isENOENT(error)) {
1700 errors.push(`Failed to remove ${localInstallDir}: ${error}`)
1701 logForDebugging(`Failed to remove local installation: ${error}`, {
1702 level: 'error',
1703 })
1704 }
1705 }
1706
1707 return { removed, errors, warnings }
1708}
1709

Callers 1

runFunction · 0.85

Calls 5

attemptNpmUninstallFunction · 0.85
rmFunction · 0.85
logForDebuggingFunction · 0.85
isENOENTFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected