UNPKG

@altostra/core

Version:

Core library for shared types and logic

1 lines 1.29 kB
"use strict";var __awaiter=this&&this.__awaiter||function(e,r,t,a){return new(t||(t=Promise))((function(n,o){function s(e){try{i(a.next(e))}catch(e){o(e)}}function c(e){try{i(a.throw(e))}catch(e){o(e)}}function i(e){var r;e.done?n(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(s,c)}i((a=a.apply(e,r||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.SLSManager=void 0;const child_process_1=require("child_process"),os_1=require("os"),Errors_1=require("../../../common/Errors");class SLSManager{package({path:e,extraParameters:r,slsTemplatePath:t}){return __awaiter(this,void 0,void 0,(function*(){const a=t&&"-c "+escapeArg(t),n=`sls package ${null!=r?r:""} ${null!=a?a:""}`;return yield new Promise((r,t)=>(0,child_process_1.exec)(n,{cwd:e},(e,a)=>{if(e){const r=`Serverless Framework CLI failed with an error. See the output below for more details: \n=====================================================================\nServerless Framework command: ${n} \n`+a+"=====================================================================\n";t(Errors_1.AltoError.wrapError(e,{message:r}))}r()}))}))}}function escapeArg(e){return"win32"===(0,os_1.platform)()?`"${e.replace('"','""')}"`:`$'${e.replace("'","\\'")}'`}exports.SLSManager=SLSManager;