Skip to content

Commit 977c2c3

Browse files
committed
fix(pm-i): don't modify global array!
1 parent cbf800f commit 977c2c3

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/generators/pm.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ const INSTALL_COMMANDS = [
77
["yarn", "add"],
88
["pnpm", "install"],
99
["bun", "install"],
10-
];
10+
] as const;
11+
12+
const NYPM_COMMAND = ["npx nypm", "install"] as const;
1113

1214
const RUN_COMMANDS = [
1315
["npm", "npx"],
1416
["pnpm", "pnpm dlx"],
1517
["bun", "bunx"],
16-
];
18+
] as const;
1719

1820
export const pmInstall = defineGenerator({
1921
name: "pm-install",
@@ -26,17 +28,18 @@ export const pmInstall = defineGenerator({
2628
};
2729
}
2830

29-
if (args.auto ?? true) {
30-
INSTALL_COMMANDS.unshift(["npx nypm", "i"]);
31-
}
32-
3331
let versionSuffix = "";
3432
if (args.version) {
3533
versionSuffix =
3634
typeof args.version === "string" ? `@${args.version}` : `@^${version}`;
3735
}
3836

39-
const contents = INSTALL_COMMANDS.map(
37+
const commands =
38+
args.auto === false
39+
? INSTALL_COMMANDS
40+
: [NYPM_COMMAND, ...INSTALL_COMMANDS];
41+
42+
const contents = commands.map(
4043
([cmd, install]) =>
4144
`# ${cmd.includes("nypm") ? "✨ Auto-detect" : cmd}\n${cmd} ${install}${args.dev ? " -D" : ""} ${name}${versionSuffix}`,
4245
);

0 commit comments

Comments
 (0)