UNPKG

ask-cli

Version:

Alexa Skills Kit (ASK) Command Line Interfaces

48 lines (47 loc) 2.02 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.NodejsRunFlow = void 0; const path_1 = require("path"); const fs_1 = require("fs"); const constants_1 = require("../../../utils/constants"); const cli_error_1 = __importDefault(require("../../../exceptions/cli-error")); const abstract_run_flow_1 = require("./abstract-run-flow"); class NodejsRunFlow extends abstract_run_flow_1.AbstractRunFlow { static canHandle(runtime) { return runtime === constants_1.RUNTIME.NODE; } constructor({ skillInvocationInfo, waitForAttach, debugPort, token, skillId, runRegion, watch }) { const skillFolderPath = (0, path_1.join)(process.cwd(), skillInvocationInfo.skillCodeFolderName); const script = (0, path_1.join)(skillFolderPath, constants_1.RUN.NODE.SCRIPT_LOCATION); if (!(0, fs_1.existsSync)(script)) { throw new cli_error_1.default("ask-sdk-local-debug cannot be found. Please install ask-sdk-local-debug to your skill code project. " + "Refer https://www.npmjs.com/package/ask-sdk-local-debug for more info."); } const execMap = waitForAttach ? { js: `node --inspect-brk=${debugPort}`, } : undefined; super({ execMap, script, args: [ "--accessToken", `"${token}"`, "--skillId", skillId, "--handlerName", skillInvocationInfo.handlerName, "--skillEntryFile", (0, path_1.join)(skillFolderPath, `${skillInvocationInfo.skillFileName}.js`), "--region", runRegion, ], watch: watch ? `${skillInvocationInfo.skillCodeFolderName}` : watch, }); } } exports.NodejsRunFlow = NodejsRunFlow;