mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
This adds support for `--use-bun` to `create-next-app` to use `bun install` when bootstrapping a new project. ``` npx create-next-app --use-bun ``` As with Yarn and pnpm, it reads from `npm_config_user_agent` to determine if the user ran `bunx create-next-app`. If so, it defaults to using Bun. ```sh bunx create-next-app ``` ## For Contributors ### Improving Documentation - [x] Run `pnpm prettier-fix` - [x] `pnpm build && pnpm lint` - [x] Added test to `test/integration/create-next-app/package-manager.test.ts` ---------
20 lines
371 B
TypeScript
20 lines
371 B
TypeScript
export type PackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun'
|
|
|
|
export function getPkgManager(): PackageManager {
|
|
const userAgent = process.env.npm_config_user_agent || ''
|
|
|
|
if (userAgent.startsWith('yarn')) {
|
|
return 'yarn'
|
|
}
|
|
|
|
if (userAgent.startsWith('pnpm')) {
|
|
return 'pnpm'
|
|
}
|
|
|
|
if (userAgent.startsWith('bun')) {
|
|
return 'bun'
|
|
}
|
|
|
|
return 'npm'
|
|
}
|