From f8094df3319e9ff6f0dd17d1ac956d92dd3e446a Mon Sep 17 00:00:00 2001 From: amorozov Date: Fri, 21 Jun 2024 18:23:54 +0300 Subject: [PATCH] feature: added 'ExecuteAndGetOutputC' to process_execution --- .../process/process_execution/process_execution.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/os/process/process_execution/process_execution.go b/pkg/os/process/process_execution/process_execution.go index 68fb90a..5e488d8 100644 --- a/pkg/os/process/process_execution/process_execution.go +++ b/pkg/os/process/process_execution/process_execution.go @@ -3,7 +3,17 @@ package process_execution import "os/exec" func ExecuteAndGetOutput(command string, args ...string) (string, error) { - outputBytes, err := exec.Command(command, args...).CombinedOutput() + return ExecuteAndGetOutputC(nil, command, args...) +} + +func ExecuteAndGetOutputC(cfg func(*exec.Cmd), command string, args ...string) (string, error) { + process := exec.Command(command, args...) + + if cfg != nil { + cfg(process) + } + + outputBytes, err := process.CombinedOutput() outputString := "" if outputBytes != nil && len(outputBytes) > 0 {