UNPKG

ask-cli-x

Version:

Alexa Skills Kit (ASK) Command Line Interfaces

27 lines (26 loc) 1.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parseACDLLine = void 0; const acdl_1 = require("@alexa/acdl"); const parseACDLLine = (acdl, namespace) => { var _a, _b; // Yep, hacky. Module expects a namespace and then anything. const moduleWrapper = `namespace ${namespace} ${acdl}`; const [module, errors] = (0, acdl_1.parseACDLFile)(namespace, moduleWrapper); if (errors && (errors === null || errors === void 0 ? void 0 : errors.length) > 0) { throw new Error(errors.map((e) => e.message).join()); } else if (!module || !module.expressions || module.expressions.length === 0) { throw new Error("Something went wrong."); } else if (!module.expressions || module.expressions.length === 0) { throw new Error("Provide an expression!"); } const exp = module.expressions[0]; if (exp instanceof acdl_1.NameDeclaration) { return new acdl_1.NameDeclaration(new acdl_1.Name((_b = (_a = exp.name) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.replace(`${namespace}.`, "")), exp.type, exp.expression); } return exp; }; exports.parseACDLLine = parseACDLLine;