mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-02-15 14:03:06 +02:00
move platform specific code to dedicated platform files
This commit is contained in:
parent
a5adfaee8a
commit
32f4d09e89
@ -4,7 +4,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"runtime"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
@ -74,25 +73,6 @@ func sanitisedCommandOutput(output []byte, err error) (string, error) {
|
|||||||
return outputString, nil
|
return outputString, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getPlatform() *Platform {
|
|
||||||
switch runtime.GOOS {
|
|
||||||
case "windows":
|
|
||||||
return &Platform{
|
|
||||||
os: "windows",
|
|
||||||
shell: "cmd",
|
|
||||||
shellArg: "/c",
|
|
||||||
escapedQuote: "\\\"",
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return &Platform{
|
|
||||||
os: runtime.GOOS,
|
|
||||||
shell: "bash",
|
|
||||||
shellArg: "-c",
|
|
||||||
escapedQuote: "\"",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetOpenCommand get open command
|
// GetOpenCommand get open command
|
||||||
func (c *OSCommand) GetOpenCommand() (string, string, error) {
|
func (c *OSCommand) GetOpenCommand() (string, string, error) {
|
||||||
//NextStep open equivalents: xdg-open (linux), cygstart (cygwin), open (OSX)
|
//NextStep open equivalents: xdg-open (linux), cygstart (cygwin), open (OSX)
|
||||||
|
16
pkg/commands/os_default_platform.go
Normal file
16
pkg/commands/os_default_platform.go
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// +build !windows
|
||||||
|
|
||||||
|
package commands
|
||||||
|
|
||||||
|
import (
|
||||||
|
"runtime"
|
||||||
|
)
|
||||||
|
|
||||||
|
func getPlatform() *Platform {
|
||||||
|
return &Platform{
|
||||||
|
os: runtime.GOOS,
|
||||||
|
shell: "bash",
|
||||||
|
shellArg: "-c",
|
||||||
|
escapedQuote: "\"",
|
||||||
|
}
|
||||||
|
}
|
10
pkg/commands/os_windows.go
Normal file
10
pkg/commands/os_windows.go
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package commands
|
||||||
|
|
||||||
|
func getPlatform() *Platform {
|
||||||
|
return &Platform{
|
||||||
|
os: "windows",
|
||||||
|
shell: "cmd",
|
||||||
|
shellArg: "/c",
|
||||||
|
escapedQuote: "\\\"",
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user