Skip to content

Commit

Permalink
chore: revert "fix(spin): pause tea before running the sub-process (#621
Browse files Browse the repository at this point in the history
)"
  • Loading branch information
aymanbagabas committed Jul 24, 2024
1 parent fb3191b commit 5d96f84
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions spin/spin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -88,7 +91,7 @@ func commandStart(command []string) tea.Cmd {
output: bothbuf.String(),
status: status,
}
})
}
}

func (m model) Init() tea.Cmd {
Expand Down

0 comments on commit 5d96f84

Please sign in to comment.