Skip to content

Commit 1245390

Browse files
authored
fix(init-stack): use correct package add commands for bun and pnpm (#886)
1 parent 9318e2b commit 1245390

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

packages/init-stack/src/index.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,19 @@ async function main(): Promise<void> {
234234
// Install dependencies
235235
console.log();
236236
console.log(colorize.bold`Installing dependencies...`);
237-
const installCommand = packageManager === "yarn" ? "yarn add" : `${packageManager} install`;
238-
await shellNicelyFormatted(`${installCommand} ${packagesToInstall.join(' ')}`, {
237+
const installCommandMap = new Map<string, string>([
238+
["npm", "npm install"],
239+
["yarn", "yarn add"],
240+
["pnpm", "pnpm add"],
241+
["bun", "bun add"],
242+
]);
243+
const installCommand = installCommandMap.get(packageManager) ?? `${packageManager} install`;
244+
// Quote each package name to avoid shell interpretation of env-overridden values.
245+
const safePackages = packagesToInstall.map((p) => JSON.stringify(p));
246+
await shellNicelyFormatted(`${installCommand} ${safePackages.join(' ')}`, {
247+
shell: true,
248+
cwd: projectPath,
249+
});
239250
shell: true,
240251
cwd: projectPath,
241252
});

0 commit comments

Comments
 (0)