62c33c1eb7
* feat: support `pnpm` with `create-next-app` * test: add `--use-pnpm` tests * docs: mention `--use-pnpm` flag in docs * test: remove `only` * Update test/integration/create-next-app/index.test.ts Co-authored-by: Steven <steven@ceriously.com> * chore: add pnpm action setup to tests * chore: use latest pnpm * chore: debug * chore: debug * fix: fall back to `yarn` instead of `npm` * test: run all tests Co-authored-by: Steven <steven@ceriously.com>
25 lines
593 B
TypeScript
25 lines
593 B
TypeScript
import { execSync } from 'child_process'
|
|
|
|
export type PackageManager = 'npm' | 'pnpm' | 'yarn'
|
|
|
|
export function getPkgManager(): PackageManager {
|
|
try {
|
|
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'
|
|
}
|
|
}
|