docs: match dependencies in package.json instead of simply setting 'latest' (#7381)

pull/7514/head
ashu-guo 2024-04-19 10:19:50 +08:00 committed by GitHub
parent 2b0c2da232
commit 75886a8cbf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 1 deletions

View File

@ -43,10 +43,11 @@ app.use(Antd).mount('#app');
`; `;
function getDeps(code: string) { function getDeps(code: string) {
const deps = Object.assign({}, packageInfo.dependencies, packageInfo.devDependencies);
return (code.match(/from '([^']+)';\n/g) || []) return (code.match(/from '([^']+)';\n/g) || [])
.map(v => v.slice(6, v.length - 3)) .map(v => v.slice(6, v.length - 3))
.reduce((prevV, dep) => { .reduce((prevV, dep) => {
prevV[dep] = 'latest'; prevV[dep] = deps[dep] || 'latest';
return prevV; return prevV;
}, {}); }, {});
} }