UNPKG

process-rerun

Version:

The purpose of this library is - build simple and flexible interface for parallel command execution with rerun (on fail) possibility

24 lines 1.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.execute = execute; const sat_utils_1 = require("sat-utils"); const child_process_1 = require("child_process"); const error_1 = require("../error"); function execute(cmd, logProcessResult, executionHolder, execOpts = {}) { if (!(0, sat_utils_1.isString)(cmd)) { throw new error_1.ProcessRerunError('Type', `cmd (first argument should be a string), current type is ${(0, sat_utils_1.getType)(cmd)}`); } if (!(0, sat_utils_1.isObject)(executionHolder)) { throw new error_1.ProcessRerunError('Type', `executionHolder (third argument should be an object), current type is ${(0, sat_utils_1.getType)(executionHolder)}`); } if (!(0, sat_utils_1.isFunction)(logProcessResult)) { throw new error_1.ProcessRerunError('Type', `executionHolder (second argument should be a function), current type is ${(0, sat_utils_1.getType)(logProcessResult)}`); } const startTime = +Date.now(); const execProc = (0, child_process_1.exec)(cmd, execOpts, (error, stdout, stderr) => { logProcessResult(cmd, startTime, execProc, error, stdout, stderr); executionHolder.stackTrace += `${stdout}${stderr}`; }); return execProc; } //# sourceMappingURL=index.js.map