Skip to content

Commit

Permalink
fix: 修复bootstrap.js创建文件bug (ant-design#8250)
Browse files Browse the repository at this point in the history
调整判断逻辑,原逻辑会导致packages目录下文件夹内没有README.md时,报错:`TypeError: Cannot read properties of undefined (reading 'description')
`
  • Loading branch information
GuanJdoJ authored Mar 27, 2024
1 parent 058e087 commit 8f98da0
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions scripts/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,25 @@ const { yParser } = require('@umijs/utils');
access: 'public',
},
};
if (pkgJSONExists) {
const pkg = require(pkgJSONPath);
[
'dependencies',
'devDependencies',
'peerDependencies',
'bin',
'version',
'files',
'authors',
'types',
'sideEffects',
'main',
'module',
'description',
].forEach((key) => {
if (pkg[key]) json[key] = pkg[key];
});
}
writeFileSync(pkgJSONPath, `${JSON.stringify(json, null, 2)}\n`);
} else if (pkgJSONExists) {
const pkg = require(pkgJSONPath);
[
'dependencies',
'devDependencies',
'peerDependencies',
'bin',
'version',
'files',
'authors',
'types',
'sideEffects',
'main',
'module',
'description',
].forEach((key) => {
if (pkg[key]) json[key] = pkg[key];
});
}

const readmePath = join(
Expand Down

0 comments on commit 8f98da0

Please sign in to comment.