mirror of
				https://github.com/jesseduffield/lazygit.git
				synced 2025-10-30 23:57:43 +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:
		| @@ -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 | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user