Files
Umbraco-CMS/src/Umbraco.Web.UI.Client/devops/package/validate-exports.js
2024-02-12 21:23:47 +01:00

27 lines
691 B
JavaScript

import { globSync } from 'glob';
import { packageJsonExports } from './meta.js';
const validateExports = async () => {
const errors = [];
// 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'));
} else {
console.log('--- Exports validated successfully. ---');
}
};
validateExports();