From 5d96f8479decd6c1e293234931b6b9c7c95d60e3 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Wed, 24 Jul 2024 16:40:28 -0400 Subject: [PATCH] chore: revert "fix(spin): pause tea before running the sub-process (#621)" --- spin/spin.go | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/spin/spin.go b/spin/spin.go index 0555e3454..db63fa4f7 100644 --- a/spin/spin.go +++ b/spin/spin.go @@ -60,24 +60,27 @@ type finishCommandMsg struct { } func commandStart(command []string) tea.Cmd { - var args []string - if len(command) > 1 { - args = command[1:] - } + return func() tea.Msg { + var args []string + if len(command) > 1 { + args = command[1:] + } + cmd := exec.Command(command[0], args...) //nolint:gosec - cmd := exec.Command(command[0], args...) //nolint:gosec - if term.IsTerminal(os.Stdout.Fd()) { - stdout := io.MultiWriter(&bothbuf, &errbuf) - stderr := io.MultiWriter(&bothbuf, &outbuf) + 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.Stdout = stdout + cmd.Stderr = stderr + } else { + cmd.Stdout = os.Stdout + } + + _ = cmd.Run() - return tea.ExecProcess(cmd, func(error) tea.Msg { status := cmd.ProcessState.ExitCode() + if status == -1 { status = 1 } @@ -88,7 +91,7 @@ func commandStart(command []string) tea.Cmd { output: bothbuf.String(), status: status, } - }) + } } func (m model) Init() tea.Cmd {