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