Skip to content

Commit

Permalink
(fix): ShowOutput flag displays in realtime (#405)
Browse files Browse the repository at this point in the history
  • Loading branch information
hopefulTex committed Nov 29, 2023
1 parent 32c9d20 commit 5c65944
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion spin/command.go
Expand Up @@ -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,
}
Expand All @@ -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)
Expand Down

0 comments on commit 5c65944

Please sign in to comment.