Skip to content

Commit

Permalink
fix(spin): properly redirect output
Browse files Browse the repository at this point in the history
closes #690
  • Loading branch information
caarlos0 committed Dec 4, 2024
1 parent c422e76 commit 71af32c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions spin/spin.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ package spin

import (
"io"
"os"
"os/exec"
"strings"
"syscall"
"time"

"github.com/charmbracelet/gum/internal/exit"
"github.com/charmbracelet/gum/timeout"
"github.com/charmbracelet/x/term"

"github.com/charmbracelet/bubbles/spinner"
tea "github.com/charmbracelet/bubbletea"
Expand Down Expand Up @@ -68,8 +70,12 @@ func commandStart(command []string) tea.Cmd {
}

executing = exec.Command(command[0], args...) //nolint:gosec
executing.Stdout = io.MultiWriter(&bothbuf, &outbuf)
executing.Stderr = io.MultiWriter(&bothbuf, &errbuf)
if term.IsTerminal(os.Stdout.Fd()) {
executing.Stdout = io.MultiWriter(&bothbuf, &outbuf)
executing.Stderr = io.MultiWriter(&bothbuf, &errbuf)
} else {
executing.Stdout = os.Stdout
}
_ = executing.Run()
status := executing.ProcessState.ExitCode()
if status == -1 {
Expand Down

0 comments on commit 71af32c

Please sign in to comment.