Skip to content

Commit a9839b4

Browse files
caohuilinKyrieLii
authored andcommitted
fix: generator get modern plugin version error
1 parent de8f73f commit a9839b4

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

.changeset/brown-flies-agree.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@modern-js/generator-utils': patch
3+
---
4+
5+
fix: generator get modern plugin version error
6+
7+
fix: 修复生成器获取插件版本错误

packages/generator/generator-utils/src/index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,19 @@ export async function getModernPluginVersion(
9898
return getLatetPluginVersion('latest');
9999
}
100100
// get project solution version
101-
const pkgPath = path.join(
101+
let pkgPath = path.join(
102102
require.resolve(SolutionToolsMap[solution], { paths: [cwd] }),
103-
'../../../../',
103+
'../../..',
104104
'package.json',
105105
);
106+
if (solution === Solution.Module) {
107+
pkgPath = path.join(
108+
require.resolve(SolutionToolsMap[solution], { paths: [cwd] }),
109+
'../..',
110+
'package.json',
111+
);
112+
}
113+
106114
if (fs.existsSync(pkgPath)) {
107115
const pkgInfo = fs.readJSONSync(pkgPath);
108116

0 commit comments

Comments
 (0)