How to use the @serverless/core.utils.isYamlPath function in @serverless/core

To help you get started, we’ve selected a few @serverless/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github webiny / webiny-js / packages / cli / sls / template / utils.js View on Github external
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;
};