Skip to content

Commit 236b1bf

Browse files
committed
refactor(OSSLicensesBuilder): 优化许可证信息获取逻辑
- 重构了处理许可证信息的代码,提高了代码可读性和维护性 - 使用常量存储 SPDX 许可证信息,减少重复查询 - 优化了 JSON 数据处理流程,提升了数据处理效率
1 parent c783ca4 commit 236b1bf

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

source/OSSLicensesBuilder.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ function buildLicenses(outputFile, customFormat, customPath, startPath = '') {
7777
delete jsonDataWithoutLicenseText[key].licenseText;
7878
jsonDataWithoutLicenseText[key].licenseTextHash = sha256Hash;
7979
} else jsonDataWithoutLicenseText[key].licenseTextHash = "";
80-
if (spdx[value.licenses]) jsonDataWithoutLicenseText[key].licenses = spdx[value.licenses].name;
80+
const spdxItem = spdx[value.licenses]
81+
if (spdxItem) jsonDataWithoutLicenseText[key].licenses = spdxItem.name;
8182
}
8283
const jsContentWithoutLicenseText = `module.exports = ${JSON5.stringify(jsonDataWithoutLicenseText, null, 2)};`;
8384
const minifiedResultWithoutLicenseText = uglifyJS.minify(jsContentWithoutLicenseText, {

0 commit comments

Comments
 (0)