mirror of
https://github.com/hanzoai/pack.git
synced 2026-09-30 23:43:13 +00:00
* refactor(node): check engines after file-based detection for package manager Engines are now considered only if file-based detection keeps default npm, so lockfiles/configs take precedence over engines as a hint. * feat: extract yarn version from package.json > engines > yarn * test: add bun version to bun test assertion * test: update snapshots * test: add engines version extraction test * test: assert against two distinct versions we couldn't do this before the recent testing harness improvement * test: snapshot update * fix: properly handle corepack version definitions * docs: update docs on node provider detection * docs: add docs command to claude
26 lines
822 B
JavaScript
26 lines
822 B
JavaScript
const { execSync } = require('child_process');
|
|
|
|
function getPnpmVersion() {
|
|
const ua = process.env.npm_config_user_agent || "";
|
|
return /\bpnpm\/([^\s]+)/.exec(ua)?.[1] ?? null; // e.g. "8.15.6"
|
|
}
|
|
|
|
// Get Node.js version
|
|
const nodeVersion = process.version;
|
|
console.log(`Node.js version: ${nodeVersion}`);
|
|
|
|
// Get PNPM version from user agent
|
|
const pnpmVersionFromUA = getPnpmVersion();
|
|
if (pnpmVersionFromUA) {
|
|
console.log(`PNPM version (from user agent): v${pnpmVersionFromUA}`);
|
|
} else {
|
|
console.log('PNPM version (from user agent): not detected');
|
|
}
|
|
|
|
// Get PNPM version from CLI (fallback)
|
|
try {
|
|
const pnpmVersion = execSync('pnpm --version', { encoding: 'utf8' }).trim();
|
|
console.log(`PNPM version (from CLI): v${pnpmVersion}`);
|
|
} catch (error) {
|
|
console.log('PNPM version (from CLI): not available');
|
|
} |