fix(coding-agent): remove install method cache

This commit is contained in:
Mario Zechner 2026-02-03 01:45:35 +01:00
parent 4137ed787b
commit 494a7750ef
2 changed files with 13 additions and 24 deletions

View file

@ -26,39 +26,27 @@ export const isBunRuntime = !!process.versions.bun;
export type InstallMethod = "bun-binary" | "npm" | "pnpm" | "yarn" | "bun" | "unknown";
let _cachedInstallMethod: InstallMethod | undefined;
export function detectInstallMethod(): InstallMethod {
if (_cachedInstallMethod) return _cachedInstallMethod;
if (isBunBinary) {
_cachedInstallMethod = "bun-binary";
return _cachedInstallMethod;
return "bun-binary";
}
const resolvedPath = `${__dirname}\0${process.execPath || ""}`.toLowerCase();
if (resolvedPath.includes("/pnpm/") || resolvedPath.includes("/.pnpm/") || resolvedPath.includes("\\pnpm\\")) {
_cachedInstallMethod = "pnpm";
} else if (
resolvedPath.includes("/yarn/") ||
resolvedPath.includes("/.yarn/") ||
resolvedPath.includes("\\yarn\\")
) {
_cachedInstallMethod = "yarn";
} else if (isBunRuntime) {
_cachedInstallMethod = "bun";
} else if (
resolvedPath.includes("/npm/") ||
resolvedPath.includes("/node_modules/") ||
resolvedPath.includes("\\npm\\")
) {
_cachedInstallMethod = "npm";
} else {
_cachedInstallMethod = "unknown";
return "pnpm";
}
if (resolvedPath.includes("/yarn/") || resolvedPath.includes("/.yarn/") || resolvedPath.includes("\\yarn\\")) {
return "yarn";
}
if (isBunRuntime) {
return "bun";
}
if (resolvedPath.includes("/npm/") || resolvedPath.includes("/node_modules/") || resolvedPath.includes("\\npm\\")) {
return "npm";
}
return _cachedInstallMethod;
return "unknown";
}
export function getUpdateInstruction(packageName: string): string {