MCPcopy Index your code
hub / github.com/upstash/context7 / detectInstallMethod

Function detectInstallMethod

packages/cli/src/utils/update-check.ts:108–125  ·  view source on GitHub ↗
(env: NodeJS.ProcessEnv = process.env)

Source from the content-addressed store, hash-verified

106}
107
108export function detectInstallMethod(env: NodeJS.ProcessEnv = process.env): InstallMethod {
109 const execPath = env.npm_execpath?.toLowerCase() ?? "";
110 const npmCommand = env.npm_command?.toLowerCase() ?? "";
111 const userAgent = env.npm_config_user_agent?.toLowerCase() ?? "";
112
113 if (execPath.includes("pnpm") && npmCommand === "dlx") return "pnpm-dlx";
114 if (execPath.includes("pnpm")) return "pnpm-global";
115 if (execPath.includes("bun") && npmCommand === "x") return "bunx";
116 if (execPath.includes("bun")) return "bun-global";
117 if (execPath.includes("npm") && npmCommand === "exec") return "npx";
118 if (execPath.includes("npm")) return "npm-global";
119
120 if (userAgent.startsWith("pnpm/")) return "pnpm-global";
121 if (userAgent.startsWith("bun/")) return "bun-global";
122 if (userAgent.startsWith("npm/")) return "npm-global";
123
124 return "unknown";
125}
126
127export function getUpgradePlan(
128 installMethod = detectInstallMethod(),

Callers 3

getUpgradePlanFunction · 0.85
checkForUpdatesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected