@constructor-io/constructorio-connect-cli
Version:
CLI tool to enable users to interface with the Constructor Connect Ecosystem
24 lines (23 loc) • 948 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.extractTemplateType = extractTemplateType;
const errors_1 = require("@oclif/core/errors");
const types_1 = require("../types");
/**
* Checks for any nested folder that matches a known template type.
*/
function extractTemplateType(templatePath) {
for (const type of types_1.TemplateTypes) {
if (templatePath.includes(`${type}/`)) {
return type;
}
}
throw new errors_1.CLIError(`Couldn't find the template type by looking at its path: ${templatePath}`, {
suggestions: [
"Check that the template file path is correct",
"Check that your templates are in the correctly named directory for their type (e.g. 'item.jsonata' in the 'templates/item' directory",
"Check that you are using a valid template type: " +
types_1.TemplateTypes.join(", "),
],
});
}