UNPKG

liveperson-functions-cli

Version:
42 lines 1.75 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DebugController = void 0; const child_process_1 = require("child_process"); const path_1 = require("path"); const getPort = require("get-port"); const file_service_1 = require("../service/file.service"); const debug_view_1 = require("../view/debug.view"); const init_controller_1 = require("./init.controller"); class DebugController { constructor( /* istanbul ignore next */ { fileService = new file_service_1.FileService(), debugView = new debug_view_1.DebugView(), initController = new init_controller_1.InitController(), } = {}) { this.fileService = fileService; this.debugView = debugView; this.initController = initController; } /** * Executes the debug.js with the passed function * @param {IDebugConfig} { lambdaFunctions } * @memberof DebugController */ async debug({ lambdaFunctions }) { try { if (this.fileService.needUpdateBinFolder()) { await this.initController.init({ update: true }); } this.fileService.getPathToFunction(lambdaFunctions[0]); const port = await getPort({ port: getPort.makeRange(30500, 31000) }); this.debugView.showDebuggerIsRunning(port); process.env.DEBUG_PORT = `${port}`; (0, child_process_1.execFileSync)('node', [ (0, path_1.join)(process.cwd(), 'bin', 'faas-debugger.js'), lambdaFunctions[0], ]); } catch (error) { this.debugView.showErrorMessage(error.message || error.errorMsg); } } } exports.DebugController = DebugController; //# sourceMappingURL=debug.controller.js.map