(installPath: string)
| 963 | export { getGitCommitSha } |
| 964 | |
| 965 | export function deletePluginCache(installPath: string): void { |
| 966 | const fs = getFsImplementation() |
| 967 | |
| 968 | try { |
| 969 | fs.rmSync(installPath, { recursive: true, force: true }) |
| 970 | logForDebugging(`Deleted plugin cache at ${installPath}`) |
| 971 | |
| 972 | // Clean up empty parent plugin directory (cache/{marketplace}/{plugin}) |
| 973 | // Versioned paths have structure: cache/{marketplace}/{plugin}/{version} |
| 974 | const cachePath = getPluginCachePath() |
| 975 | if (installPath.includes('/cache/') && installPath.startsWith(cachePath)) { |
| 976 | const pluginDir = dirname(installPath) // e.g., cache/{marketplace}/{plugin} |
| 977 | if (pluginDir !== cachePath && pluginDir.startsWith(cachePath)) { |
| 978 | try { |
| 979 | const contents = fs.readdirSync(pluginDir) |
| 980 | if (contents.length === 0) { |
| 981 | fs.rmdirSync(pluginDir) |
| 982 | logForDebugging(`Deleted empty plugin directory at ${pluginDir}`) |
| 983 | } |
| 984 | } catch { |
| 985 | // Parent dir doesn't exist or isn't readable — skip cleanup |
| 986 | } |
| 987 | } |
| 988 | } |
| 989 | } catch (error) { |
| 990 | const errorMsg = errorMessage(error) |
| 991 | logError(toError(error)) |
| 992 | throw new Error( |
| 993 | `Failed to delete plugin cache at ${installPath}: ${errorMsg}`, |
| 994 | ) |
| 995 | } |
| 996 | } |
| 997 | |
| 998 | /** |
| 999 | * Get the git commit SHA from a git repository directory |
nothing calls this directly
no test coverage detected