genezio
Version:
Command line utility to interact with Genezio infrastructure.
42 lines (41 loc) • 1.25 kB
JavaScript
import { exec } from "child_process";
import { log } from "./logging.js";
import { debugLogger } from "./logging.js";
export function runNewProcess(command, cwd, showStdoutOutput = false, showStderrOutput = true) {
return new Promise(function (resolve) {
exec(command, { cwd }, (err, stdout, stderr) => {
if (err) {
debugLogger.error("Process exited with error:", err);
if (showStderrOutput && stderr.length > 0) {
log.info(command + " ❌");
log.info(stderr);
}
resolve(false);
}
else {
resolve(true);
}
if (showStdoutOutput) {
log.info(stdout);
}
else {
debugLogger.debug(stdout);
}
});
});
}
export function runNewProcessWithResult(command, cwd) {
return new Promise(function (resolve) {
exec(command, { cwd }, (err, stdout, stderr) => {
if (err) {
resolve(stderr);
}
else {
resolve(stdout);
}
});
});
}
export function isCI() {
return process.env["CI"] === "true";
}