MCPcopy Index your code
hub / github.com/dmno-dev/bumpy / detectPackageManager

Function detectPackageManager

packages/bumpy/src/utils/package-manager.ts:23–45  ·  view source on GitHub ↗
(rootDir: string)

Source from the content-addressed store, hash-verified

21}
22
23export async function detectPackageManager(rootDir: string): Promise<PackageManager> {
24 // Check lockfiles in priority order
25 if ((await exists(resolve(rootDir, 'bun.lock'))) || (await exists(resolve(rootDir, 'bun.lockb')))) {
26 return 'bun';
27 }
28 if (await exists(resolve(rootDir, 'pnpm-lock.yaml'))) {
29 return 'pnpm';
30 }
31 if (await exists(resolve(rootDir, 'yarn.lock'))) {
32 return 'yarn';
33 }
34 // Fallback: check packageManager field in package.json
35 try {
36 const pkg = await readJson<Record<string, unknown>>(resolve(rootDir, 'package.json'));
37 if (typeof pkg.packageManager === 'string') {
38 const name = pkg.packageManager.split('@')[0];
39 if (name === 'pnpm' || name === 'yarn' || name === 'bun') return name;
40 }
41 } catch {
42 // ignore
43 }
44 return 'npm';
45}
46
47async function getWorkspaceGlobs(rootDir: string, pm: PackageManager): Promise<string[]> {
48 // pnpm uses pnpm-workspace.yaml

Callers 6

getChangedCatalogEntriesFunction · 0.90
ciSetupCommandFunction · 0.90
initCommandFunction · 0.90
ciCheckCommandFunction · 0.90
ciSnapshotReleaseFunction · 0.90
detectWorkspacesFunction · 0.85

Calls 1

existsFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…