mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-03-05 15:15:49 +02:00
Maybe fixed the test this time
This commit is contained in:
parent
3938138ebc
commit
0e53a26d6f
@ -8,6 +8,7 @@ import (
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/kr/pty"
|
||||
)
|
||||
@ -19,7 +20,6 @@ import (
|
||||
// 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) {
|
||||
cmdOutput := []string{}
|
||||
isAlreadyClosed := false
|
||||
|
||||
splitCmd := ToArgv(command)
|
||||
cmd := exec.Command(splitCmd[0], splitCmd[1:]...)
|
||||
@ -33,11 +33,11 @@ func RunCommandWithOutputLiveWrapper(c *OSCommand, command string, output func(s
|
||||
return errorMessage, err
|
||||
}
|
||||
|
||||
var waitForBufio sync.WaitGroup
|
||||
waitForBufio.Add(1)
|
||||
|
||||
defer func() {
|
||||
if !isAlreadyClosed {
|
||||
isAlreadyClosed = true
|
||||
_ = tty.Close()
|
||||
}
|
||||
_ = tty.Close()
|
||||
}()
|
||||
|
||||
go func() {
|
||||
@ -55,13 +55,11 @@ func RunCommandWithOutputLiveWrapper(c *OSCommand, command string, output func(s
|
||||
_, _ = tty.Write([]byte(toWrite + "\n"))
|
||||
}
|
||||
}
|
||||
waitForBufio.Done()
|
||||
}()
|
||||
|
||||
if err := cmd.Wait(); err != nil {
|
||||
if !isAlreadyClosed {
|
||||
isAlreadyClosed = true
|
||||
_ = tty.Close()
|
||||
}
|
||||
waitForBufio.Wait()
|
||||
return strings.Join(cmdOutput, " "), err
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user