semantic-release-yarn
Version:
semantic-release plugin to publish a npm package with yarn
28 lines (27 loc) • 799 B
JavaScript
import _ from "lodash";
import { getError } from "./get-error.js";
const isNonEmptyString = (value) => !!(_.isString(value) && value.trim());
const VALIDATORS = {
npmPublish: _.isBoolean,
tarballDir: isNonEmptyString,
pkgRoot: isNonEmptyString,
mainWorkspace: isNonEmptyString,
};
export function verifyConfig(config) {
const errors = Object.entries(config).reduce((errors, [option, value]) => {
if (_.isNil(value)) {
return errors;
}
if (!(option in VALIDATORS)) {
return errors;
}
if (VALIDATORS[option](value)) {
return errors;
}
return [
...errors,
getError(`EINVALID${option.toUpperCase()}`, { [option]: value }),
];
}, []);
return errors;
}