Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change(create-next-app): Get-pkg-manager logic change. #50372

Merged
merged 13 commits into from
Jun 5, 2023
20 changes: 9 additions & 11 deletions packages/create-next-app/helpers/get-pkg-manager.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
export type PackageManager = 'npm' | 'pnpm' | 'yarn'

export function getPkgManager(): PackageManager {
const userAgent = process.env.npm_config_user_agent
const userAgent = process.env.npm_config_user_agent || ''

if (userAgent) {
if (userAgent.startsWith('yarn')) {
return 'yarn'
} else if (userAgent.startsWith('pnpm')) {
return 'pnpm'
} else {
return 'npm'
}
} else {
return 'npm'
if (userAgent.startsWith('yarn')) {
return 'yarn'
}

if (userAgent.startsWith('pnpm')) {
return 'pnpm'
}

return 'npm'
}