UNPKG

git-release-manager

Version:

A tool to generate release notes from git commit history

42 lines 1.47 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.runCommand = runCommand; exports.execWithErrorHandling = execWithErrorHandling; const child_process_1 = require("child_process"); const util_1 = __importDefault(require("util")); const execPromise = util_1.default.promisify(child_process_1.exec); function runCommand(cmd, onError) { var _a; try { const [command, ...args] = cmd.split(' '); const result = (0, child_process_1.spawnSync)(command, args, { encoding: 'utf8' }); if (result.status === 0) { return ((_a = result.stdout) === null || _a === void 0 ? void 0 : _a.trim()) || ''; } else { if (onError && typeof onError === 'function') { onError(cmd, result.stderr.trim(), result.status); } return null; } } catch (error) { if (onError && typeof onError === 'function') { onError(cmd, error instanceof Error ? error.message : String(error), null); } return null; } } async function execWithErrorHandling(command) { try { return await execPromise(command); } catch (error) { console.error(`Error executing "${command}":`, error); return { stdout: '' }; } } //# sourceMappingURL=cmd.js.map