Skip to content

Commit

Permalink
change(create-next-app): Get-pkg-manager logic change. (#50372)
Browse files Browse the repository at this point in the history
Simplified Get-pkg-manager logic.

---------

Co-authored-by: Steven <steven@ceriously.com>
  • Loading branch information
vinaykulk621 and styfle authored Jun 5, 2023
1 parent 419246c commit c2d7bbd
Showing 1 changed file with 9 additions and 11 deletions.
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'
}

0 comments on commit c2d7bbd

Please sign in to comment.