Skip to content

Commit

Permalink
Make install command precise
Browse files Browse the repository at this point in the history
  • Loading branch information
samchon committed Sep 10, 2024
1 parent 03bef69 commit cd868ae
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/executable/setup/PackageManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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<Manager, string>;

const devOptionTable = {
npm: "--save-dev",
pnpm: "--save-dev",
yarn: "--dev",
bun: "--dev",
npm: "-D",
pnpm: "-D",
yarn: "-D",
bun: "-d",
} as const satisfies Record<Manager, string>;

0 comments on commit cd868ae

Please sign in to comment.