heartbeat-monitor/node_modules/next/dist/esm/lib/helpers/get-pkg-manager.js
Matt Bruce bed1169443 Initial commit: Heartbeat Monitor dashboard
- Full-featured monitoring dashboard for local web apps
- Real-time status tracking with uptime percentages
- Visual sparklines for status history
- Add/Edit/Delete apps dynamically
- Categories and color coding
- Auto-refresh every 30 seconds
- API endpoints for apps and status management
2026-02-18 11:16:01 -06:00

48 lines
1.3 KiB
JavaScript

import fs from 'fs';
import path from 'path';
import { execSync } from 'child_process';
export function getPkgManager(baseDir) {
try {
for (const { lockFile, packageManager } of [
{
lockFile: 'yarn.lock',
packageManager: 'yarn'
},
{
lockFile: 'pnpm-lock.yaml',
packageManager: 'pnpm'
},
{
lockFile: 'package-lock.json',
packageManager: 'npm'
}
]){
if (fs.existsSync(path.join(baseDir, lockFile))) {
return packageManager;
}
}
const userAgent = process.env.npm_config_user_agent;
if (userAgent) {
if (userAgent.startsWith('yarn')) {
return 'yarn';
} else if (userAgent.startsWith('pnpm')) {
return 'pnpm';
}
}
try {
execSync('yarn --version', {
stdio: 'ignore'
});
return 'yarn';
} catch {
execSync('pnpm --version', {
stdio: 'ignore'
});
return 'pnpm';
}
} catch {
return 'npm';
}
}
//# sourceMappingURL=get-pkg-manager.js.map