Skip to content

Commit 50986c8

Browse files
committed
fix: pnpm support
1 parent c749610 commit 50986c8

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

scripts/postinstall.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const AgentCommands = {
1212
npm: "npm i",
1313
yarn: "yarn add",
1414
pnpm: "pnpm add",
15-
cnpm: "cnpm i"
15+
cnpm: "cnpm i",
1616
};
1717

1818
function loadModule(name) {
@@ -28,7 +28,7 @@ function installModules(names) {
2828
names = Array.isArray(names) ? names : [names];
2929
execSync(`${command} ${names.join(" ")}`, {
3030
stdio: "inherit",
31-
cwd: userRoot
31+
cwd: userRoot,
3232
});
3333
}
3434

@@ -52,8 +52,13 @@ function switchVersion(version) {
5252
}
5353
const files = fs.readdirSync(versionPath);
5454

55-
files.forEach(f => {
56-
fs.copyFileSync(path.join(versionPath, f), path.join(dist, f));
55+
files.forEach((f) => {
56+
const dfile = path.join(dist, f);
57+
try {
58+
// pnpm fix
59+
fs.unlinkSync(dfile);
60+
} catch (_) {}
61+
fs.copyFileSync(path.join(versionPath, f), dfile);
5762
});
5863

5964
switchPeerdependencies(version);

0 commit comments

Comments
 (0)