UNPKG

sap-cap-debugger

Version:

NPX tool for remote debugging SAP CAP applications on Cloud Foundry (CAP v7 and earlier)

63 lines 1.98 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CommandExecutor = void 0; const execa = require("execa"); class CommandExecutor { constructor(logger) { this.logger = logger; } async execute(command, args = [], options = {}) { try { this.logger.debug(`Executing: ${command} ${args.join(' ')}`); const result = await execa(command, args, { ...options, stdio: 'pipe', encoding: 'utf8' }); return { success: true, output: result.stdout, exitCode: result.exitCode }; } catch (error) { this.logger.debug(`Command failed: ${error.message}`); return { success: false, output: error.stdout || '', error: error.message, exitCode: error.exitCode }; } } async executeWithOutput(command, args = [], options = {}) { try { this.logger.debug(`Executing with output: ${command} ${args.join(' ')}`); const result = await execa(command, args, { ...options, stdio: 'inherit', encoding: 'utf8' }); return { success: true, output: '', exitCode: result.exitCode }; } catch (error) { this.logger.debug(`Command with output failed: ${error.message}`); return { success: false, output: '', error: error.message, exitCode: error.exitCode }; } } async checkCommandExists(command) { const result = await this.execute('which', [command]); return result.success; } } exports.CommandExecutor = CommandExecutor; //# sourceMappingURL=command.js.map