Skip to content

Commit 9bf2b3f

Browse files
authored
Merge pull request #2 from FriendsOfShopware/feat/stream-command-output-to-terminal
feat: stream command output to terminal during deployment
2 parents 6ce5736 + 6394cec commit 9bf2b3f

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

internal/deployment/deployment.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ func Run(args []string) error {
1717
return fmt.Errorf("failed to execute command: %w", err)
1818
}
1919

20-
fmt.Print(result.Output)
21-
2220
composerData, err := ReadComposerData("composer.json")
2321
if err != nil {
2422
fmt.Fprintf(os.Stderr, "\nWarning: Failed to read composer.json: %v\n", err)

internal/deployment/executor.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ package deployment
22

33
import (
44
"bytes"
5+
"io"
6+
"os"
57
"os/exec"
68
"strings"
79
"time"
810
)
911

10-
// Execute runs a command and captures its output
12+
// Execute runs a command and streams its output to the terminal while capturing it
1113
func Execute(command string) (*ExecutionResult, error) {
1214
parts := strings.Fields(command)
1315
if len(parts) == 0 {
@@ -17,8 +19,8 @@ func Execute(command string) (*ExecutionResult, error) {
1719
cmd := exec.Command(parts[0], parts[1:]...)
1820

1921
var outputBuffer bytes.Buffer
20-
cmd.Stdout = &outputBuffer
21-
cmd.Stderr = &outputBuffer
22+
cmd.Stdout = io.MultiWriter(os.Stdout, &outputBuffer)
23+
cmd.Stderr = io.MultiWriter(os.Stderr, &outputBuffer)
2224

2325
startTime := time.Now()
2426
err := cmd.Run()

0 commit comments

Comments
 (0)