mirror of
https://github.com/jesseduffield/lazygit.git
synced 2024-12-04 10:34:55 +02:00
Cache binary paths
Turns out that with our secureexec package (which we only use on windows due to a windows security thing),
This commit is contained in:
parent
b30ec538fb
commit
ad72a1f5a3
@ -21,11 +21,25 @@ import (
|
||||
// you call `git status` from the command line directly but no harm in playing it
|
||||
// safe.
|
||||
|
||||
var pathCache = map[string]string{}
|
||||
|
||||
func Command(name string, args ...string) *exec.Cmd {
|
||||
bin, err := safeexec.LookPath(name)
|
||||
if err != nil {
|
||||
bin = name
|
||||
path := getPath(name)
|
||||
|
||||
return exec.Command(path, args...)
|
||||
}
|
||||
|
||||
func getPath(name string) string {
|
||||
if path, ok := pathCache[name]; ok {
|
||||
return path
|
||||
}
|
||||
|
||||
return exec.Command(bin, args...)
|
||||
path, err := safeexec.LookPath(name)
|
||||
if err != nil {
|
||||
pathCache[name] = name
|
||||
return name
|
||||
}
|
||||
|
||||
pathCache[name] = path
|
||||
return path
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user