UNPKG

projex

Version:
32 lines (31 loc) 1.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.runOnlyCommand = void 0; const logger_1 = require("../logger"); const child_process_1 = require("child_process"); /** * The `runOnlyCommand` function is a TypeScript function that executes a command and returns a promise * that resolves with the output of the command. * @param {string} command - The `command` parameter is a string that represents the command you want * to run. It can be any valid command that can be executed in a shell environment. * @returns The function `runOnlyCommand` returns a Promise that resolves to a string. */ const runOnlyCommand = (command) => { const task = (0, child_process_1.spawn)(`${command}`, [], { shell: true, }); return new Promise(function (resolve) { // Método para imprimir el log normal task.stdout.on("data", (data) => { logger_1.log.debug(data.toString()); resolve(data.toString()); }); // Método para imprimir el log de error task.stderr.on("data", function (data) { logger_1.log.debug("Error running the command: " + command); logger_1.log.error(data.toString()); process.exit(1); }); }); }; exports.runOnlyCommand = runOnlyCommand;