1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-19 00:28:03 +02:00

factor out platform specific logic into a struct on state

This commit is contained in:
Jesse Duffield
2018-08-09 13:14:24 +10:00
parent ce8884f509
commit 5cc34e7801
2 changed files with 30 additions and 10 deletions

View File

@ -8,7 +8,6 @@ import (
"os"
"os/exec"
"regexp"
"runtime"
"strings"
"time"
@ -118,20 +117,12 @@ func mergeGitStatusFiles(oldGitFiles, newGitFiles []GitFile) []GitFile {
return result
}
func platformShell() (string, string) {
if runtime.GOOS == "windows" {
return "cmd", "/c"
}
return "bash", "-c"
}
func runDirectCommand(command string) (string, error) {
timeStart := time.Now()
commandLog(command)
shell, shellArg := platformShell()
cmdOut, err := exec.
Command(shell, shellArg, command).
Command(state.Platform.shell, state.Platform.shellArg, command).
CombinedOutput()
devLog("run direct command time for command: ", command, time.Now().Sub(timeStart))
return sanitisedCommandOutput(cmdOut, err)