UNPKG

@alphabin/trx

Version:

TRX reporter for Playwright tests with Azure Blob Storage upload support

49 lines (48 loc) 1.35 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.exec = void 0; exports.execCommand = execCommand; exports.commandExists = commandExists; exports.getEnvVar = getEnvVar; const child_process_1 = require("child_process"); const util_1 = require("util"); const logger_util_1 = __importDefault(require("./logger.util")); /** * Promisified exec command */ exports.exec = (0, util_1.promisify)(child_process_1.exec); /** * Executes a command and returns the trimmed stdout output */ async function execCommand(command) { try { logger_util_1.default.debug(`Executing command: ${command}`); const { stdout } = await (0, exports.exec)(command); return stdout.trim(); } catch (error) { logger_util_1.default.debug(`Command failed: ${command}`, error); return ''; } } /** * Checks if a command exists by running it with --version */ async function commandExists(command) { try { await (0, exports.exec)(`${command} --version`); return true; } catch { return false; } } /** * Gets environment variable value if it exists */ function getEnvVar(name) { return process.env[name]; }