@boostercloud/cli
Version:
CLI of the Booster Framework, the next level of abstraction for cloud-native applications
19 lines (18 loc) • 884 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.LiveProcess = void 0;
const execa = require("execa");
const process = require("process");
const _1 = require(".");
const effect_1 = require("@boostercloud/framework-types/dist/effect");
const errors_1 = require("../../common/errors");
const exec = (command, cwd) => (0, effect_1.tryCatchPromise)(async () => {
const { stdout, stderr } = await execa.command(command, { cwd });
const result = `
${stderr ? `There were some issues running the command: ${stderr}\n` : ''}
${stdout}
`;
return result;
}, (reason) => new _1.ProcessError((0, errors_1.unknownToError)(reason)));
const cwd = () => (0, effect_1.tryCatch)(() => process.cwd(), (reason) => new _1.ProcessError((0, errors_1.unknownToError)(reason)));
exports.LiveProcess = effect_1.Layer.fromValue(_1.ProcessService)({ exec, cwd });