From cd868ae10c82d5566eeecbbfb4a56c756ccd7f22 Mon Sep 17 00:00:00 2001 From: Jeongho Nam Date: Tue, 10 Sep 2024 16:05:31 +0900 Subject: [PATCH] Make install command precise --- src/executable/setup/PackageManager.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/executable/setup/PackageManager.ts b/src/executable/setup/PackageManager.ts index 340db54d2f..decd067e49 100644 --- a/src/executable/setup/PackageManager.ts +++ b/src/executable/setup/PackageManager.ts @@ -40,14 +40,14 @@ export class PackageManager { modulo: string; version: string; }): boolean { - const cmd = installCmdTable[this.manager]; - const option = props.dev ? devOptionTable[this.manager] : ""; - const middle: string = `${cmd} ${option}` as const; - CommandExecutor.run( - `${this.manager} ${middle} ${props.modulo}${ - props.version ? `@${props.version}` : "" - }`, - ); + const middle: string = [ + installCmdTable[this.manager], + props.dev ? devOptionTable[this.manager] : "", + ] + .filter((str) => !!str.length) + .join(" "); + const modulo: string = `${props.modulo}${props.version ? `@${props.version}` : ""}`; + CommandExecutor.run([this.manager, middle, modulo].join(" ")); return true; } @@ -72,15 +72,15 @@ export namespace Package { type Manager = "npm" | "pnpm" | "yarn" | "bun"; const installCmdTable = { - npm: "install", + npm: "i", pnpm: "add", yarn: "add", bun: "add", } as const satisfies Record; const devOptionTable = { - npm: "--save-dev", - pnpm: "--save-dev", - yarn: "--dev", - bun: "--dev", + npm: "-D", + pnpm: "-D", + yarn: "-D", + bun: "-d", } as const satisfies Record;