1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-07 01:09:45 +02:00

Hopefully fixed circleci

This commit is contained in:
mjarkk
2018-10-31 19:25:52 +01:00
parent 05f0e5120a
commit 3938138ebc

View File

@ -19,6 +19,7 @@ import (
// NOTE: You don't have to include a enter in the return data this function will do that for you // NOTE: You don't have to include a enter in the return data this function will do that for you
func RunCommandWithOutputLiveWrapper(c *OSCommand, command string, output func(string) string) (errorMessage string, codeError error) { func RunCommandWithOutputLiveWrapper(c *OSCommand, command string, output func(string) string) (errorMessage string, codeError error) {
cmdOutput := []string{} cmdOutput := []string{}
isAlreadyClosed := false
splitCmd := ToArgv(command) splitCmd := ToArgv(command)
cmd := exec.Command(splitCmd[0], splitCmd[1:]...) cmd := exec.Command(splitCmd[0], splitCmd[1:]...)
@ -32,7 +33,12 @@ func RunCommandWithOutputLiveWrapper(c *OSCommand, command string, output func(s
return errorMessage, err return errorMessage, err
} }
defer func() { _ = tty.Close() }() defer func() {
if !isAlreadyClosed {
isAlreadyClosed = true
_ = tty.Close()
}
}()
go func() { go func() {
// Regex to cleanup the command output // Regex to cleanup the command output
@ -52,6 +58,10 @@ func RunCommandWithOutputLiveWrapper(c *OSCommand, command string, output func(s
}() }()
if err := cmd.Wait(); err != nil { if err := cmd.Wait(); err != nil {
if !isAlreadyClosed {
isAlreadyClosed = true
_ = tty.Close()
}
return strings.Join(cmdOutput, " "), err return strings.Join(cmdOutput, " "), err
} }