From 91fc6b41bc82d6cc5436756e5c403518a1f00417 Mon Sep 17 00:00:00 2001 From: Nicolas Sutter Date: Wed, 15 Nov 2023 10:11:53 +0100 Subject: [PATCH] feat: make users choose their package manager manually --- bin/bin.ts | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/bin/bin.ts b/bin/bin.ts index 76740c5..de2ca59 100644 --- a/bin/bin.ts +++ b/bin/bin.ts @@ -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' }, )