fix: Simplify scripts/updatePublint.js (#527)

This commit is contained in:
Lachlan Collins
2023-12-18 14:35:53 +11:00
committed by GitHub
parent 156f65436c
commit 94803b4cae
3 changed files with 322 additions and 381 deletions

View File

@@ -30,21 +30,9 @@ const injectVersions = (input) => {
const dataWithVersions = injectVersions(dataWithoutVersions);
const output = await Promise.all(
dataWithVersions.map(async (pkg) => {
try {
return await processPackage(pkg);
} catch (error) {
console.log(error.message);
}
})
dataWithVersions.map((pkg) => processPackage(pkg).catch((error) => console.log(error.message)))
).then((values) => {
let versions = {};
for (const value of values) {
if (value) {
versions[value.name] = value.valid;
}
}
return versions;
return values.reduce((result, value) => Object.assign(result, value), {});
});
writeFileSync('src/lib/data/publint.json', JSON.stringify(output));
@@ -73,5 +61,5 @@ async function processPackage(pkg) {
const pkgDir = files.length ? files[0].name.split('/')[0] : 'package';
const { messages } = await publint({ pkgDir, vfs, level: 'warning' });
return { name: pkg.npm, valid: messages.length === 0 };
return { [pkg.npm]: { valid: messages.length === 0 } };
}