Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
feat: make users choose their package manager manually
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolassutter committed Nov 15, 2023
1 parent 0b3dea6 commit 91fc6b4
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion bin/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,32 @@ program
}

try {
const installCommands = {
npm: `npm install -D ${deps.join(' ')}`,
yarn: `yarn add -D ${deps.join(' ')}`,
pnpm: `pnpm add -D ${deps.join(' ')}`,
bun: `bun add -D ${deps.join(' ')}`
}

const { packageManager } = await inquirer.prompt<{
packageManager: keyof typeof installCommands
}>([
{
message: 'What is your package manager?',
name: 'packageManager',
default: 'npm',
type: 'list',
choices: [
{ name: 'npm', value: 'npm' satisfies keyof typeof installCommands },
{ name: 'yarn', value: 'yarn' satisfies keyof typeof installCommands },
{ name: 'pnpm', value: 'pnpm' satisfies keyof typeof installCommands },
{ name: 'bun', value: 'bun' satisfies keyof typeof installCommands }
],
}
])

const execaRes = execaCommand(
`npx --package=@antfu/ni ni --save-dev ${deps.join(' ')}`,
installCommands[packageManager],
{ env: { FORCE_COLOR: 'true' }, stdio: 'inherit' },
)

Expand Down

0 comments on commit 91fc6b4

Please sign in to comment.