collect errors

This commit is contained in:
Mads Rasmussen
2024-02-12 21:18:26 +01:00
parent 6ff6c91f74
commit 14ebb6edc7

View File

@@ -5,14 +5,24 @@ const packageJsonPath = 'package.json';
const packageJsonData = JSON.parse(readFileSync(packageJsonPath).toString());
const packageJsonExports = packageJsonData.exports;
// Iterate over the exports in package.json
for (const [key, value] of Object.entries(packageJsonExports || {})) {
if (value) {
const jsFiles = await globSync(value);
const validateExports = async () => {
const errors = [];
// Log an error if the export from the package.json does not exist in the build output
if (jsFiles.length === 0) {
console.error(`Could not find export: ${key} -> ${value} in the build output.`);
// Iterate over the exports in package.json
for (const [key, value] of Object.entries(packageJsonExports || {})) {
if (value) {
const jsFiles = await globSync(value);
// Log an error if the export from the package.json does not exist in the build output
if (jsFiles.length === 0) {
errors.push(`Could not find export: ${key} -> ${value} in the build output.`);
}
}
}
}
if (errors.length > 0) {
throw new Error(errors.join('\n'));
}
};
validateExports();