feat: get root dir from git
This commit is contained in:
commit
b48e967e09
|
@ -0,0 +1,18 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
"os/exec"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func RootDir() string {
|
||||||
|
cmdOut, err := exec.Command("git", "rev-parse", "--show-toplevel").Output()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("exec.Command: %s", err)
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
rootDir := strings.TrimSpace(string(cmdOut))
|
||||||
|
return rootDir
|
||||||
|
}
|
Loading…
Reference in New Issue