Files
actions-ansi-to-html/node_modules/@semantic-release/changelog/lib/verify.js
T
2025-11-11 06:53:11 -05:00

28 lines
757 B
JavaScript

const {isString, isNil} = require('lodash');
const AggregateError = require('aggregate-error');
const getError = require('./get-error');
const resolveConfig = require('./resolve-config');
const isNonEmptyString = value => isString(value) && value.trim();
const VALIDATORS = {
changelogFile: isNonEmptyString,
changelogTitle: isNonEmptyString,
};
module.exports = pluginConfig => {
const options = resolveConfig(pluginConfig);
const errors = Object.entries(options).reduce(
(errors, [option, value]) =>
!isNil(value) && !VALIDATORS[option](value)
? [...errors, getError(`EINVALID${option.toUpperCase()}`, {[option]: value})]
: errors,
[]
);
if (errors.length > 0) {
throw new AggregateError(errors);
}
};