diff --git a/spin/command.go b/spin/command.go index 5334eaf..1f7f3bf 100644 --- a/spin/command.go +++ b/spin/command.go @@ -24,6 +24,7 @@ func (o Options) Run() error { title: o.TitleStyle.ToLipgloss().Render(o.Title), command: o.Command, align: o.Align, + showOutput: o.ShowOutput && isTTY, timeout: o.Timeout, hasTimeout: o.Timeout > 0, } @@ -44,7 +45,9 @@ func (o Options) Run() error { } if o.ShowOutput { - if isTTY { + // BubbleTea writes the View() to stderr. + // If the program is being piped then put the accumulated output in stdout. + if !isTTY { _, err := os.Stdout.WriteString(m.stdout) if err != nil { return fmt.Errorf("failed to write to stdout: %w", err)