summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAyman Bagabas <ayman.bagabas@gmail.com>2024-11-15 13:53:27 -0500
committerGitHub <noreply@github.com>2024-11-15 15:53:27 -0300
commit7bdd189616935c155e64403b629d2afa05277614 (patch)
tree9da7f7a131ae7599bd865ddabc3df5061b77e9a3
parent6a05246f5339d5671caedef93f21901ded174b0b (diff)
fix(spin): indenting lines when command is piped (#636)HEADmain
We don't need to check for isatty, always store the output to the designated buffer. Fixes: https://github.com/charmbracelet/gum/issues/607
-rw-r--r--spin/spin.go18
1 files changed, 3 insertions, 15 deletions
diff --git a/spin/spin.go b/spin/spin.go
index db63fa4..26c933f 100644
--- a/spin/spin.go
+++ b/spin/spin.go
@@ -16,14 +16,12 @@ package spin
import (
"io"
- "os"
"os/exec"
"strings"
"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"
@@ -65,22 +63,12 @@ func commandStart(command []string) tea.Cmd {
if len(command) > 1 {
args = command[1:]
}
- cmd := exec.Command(command[0], args...) //nolint:gosec
-
- if term.IsTerminal(os.Stdout.Fd()) {
- stdout := io.MultiWriter(&bothbuf, &errbuf)
- stderr := io.MultiWriter(&bothbuf, &outbuf)
-
- cmd.Stdout = stdout
- cmd.Stderr = stderr
- } else {
- cmd.Stdout = os.Stdout
- }
+ cmd := exec.Command(command[0], args...) //nolint:gosec
+ cmd.Stdout = io.MultiWriter(&bothbuf, &outbuf)
+ cmd.Stderr = io.MultiWriter(&bothbuf, &errbuf)
_ = cmd.Run()
-
status := cmd.ProcessState.ExitCode()
-
if status == -1 {
status = 1
}