5cd31e41ca
Gracefully parse the environment package manager when calling `create-next-app` instead of passing extra arguments. Reference: #41090 ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see `contributing.md` Co-authored-by: Balázs Orbán <info@balazsorban.com>
17 lines
377 B
TypeScript
17 lines
377 B
TypeScript
export type PackageManager = 'npm' | 'pnpm' | 'yarn'
|
|
|
|
export function getPkgManager(): PackageManager {
|
|
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'
|
|
}
|
|
}
|