fix package manager detection

This commit is contained in:
Aman Varshney
2025-02-13 10:48:42 +05:30
parent 0b3405c743
commit 7481beea90
6 changed files with 27 additions and 26 deletions

View File

@@ -0,0 +1,16 @@
export type PackageManager = "npm" | "pnpm" | "yarn" | "bun";
export const getUserPkgManager: () => PackageManager = () => {
const userAgent = process.env.npm_config_user_agent;
if (userAgent?.startsWith("yarn")) {
return "yarn";
}
if (userAgent?.startsWith("pnpm")) {
return "pnpm";
}
if (userAgent?.startsWith("bun")) {
return "bun";
}
return "npm";
};