@semantic-release/npm
Version:
semantic-release plugin to publish a npm package
23 lines (18 loc) • 639 B
JavaScript
import { isBoolean, isNil, isString } from "lodash-es";
import getError from "./get-error.js";
const isNonEmptyString = (value) => isString(value) && value.trim();
const VALIDATORS = {
npmPublish: isBoolean,
tarballDir: isNonEmptyString,
pkgRoot: isNonEmptyString,
};
export default function ({ npmPublish, tarballDir, pkgRoot }) {
const errors = Object.entries({ npmPublish, tarballDir, pkgRoot }).reduce(
(errors, [option, value]) =>
!isNil(value) && !VALIDATORS[option](value)
? [...errors, getError(`EINVALID${option.toUpperCase()}`, { [option]: value })]
: errors,
[]
);
return errors;
}