Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const getTemplate = async inputs => {
const template = inputs.template || {};
if (typeof template === "string") {
if (
(!utils.isJsonPath(template) && !utils.isYamlPath(template)) ||
!(await utils.fileExists(template))
) {
throw Error("the referenced template path does not exist");
}
return utils.readFile(template);
} else if (typeof template !== "object") {
throw Error(
"the template input could either be an object, or a string path to a template file"
);
}
return template;
};