MCPcopy
hub / github.com/t3-oss/create-t3-app / getUserPkgManager

Function getUserPkgManager

cli/src/utils/getUserPkgManager.ts:3–21  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1export type PackageManager = "npm" | "pnpm" | "yarn" | "bun";
2
3export const getUserPkgManager: () => PackageManager = () => {
4 // This environment variable is set by npm and yarn but pnpm seems less consistent
5 const userAgent = process.env.npm_config_user_agent;
6
7 if (userAgent) {
8 if (userAgent.startsWith("yarn")) {
9 return "yarn";
10 } else if (userAgent.startsWith("pnpm")) {
11 return "pnpm";
12 } else if (userAgent.startsWith("bun")) {
13 return "bun";
14 } else {
15 return "npm";
16 }
17 } else {
18 // If no user agent is set, assume npm
19 return "npm";
20 }
21};

Callers 7

mainFunction · 0.85
renderTitleFunction · 0.85
createProjectFunction · 0.85
installDependenciesFunction · 0.85
logNextStepsFunction · 0.85
runCliFunction · 0.85
dynamicEslintInstallerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected