feat: get root dir from git command

This commit is contained in:
Urko 2023-02-15 18:13:58 +01:00
parent ac1555a57c
commit 0d546f7824
1 changed files with 18 additions and 0 deletions

18
pkg/util/path.go Normal file
View File

@ -0,0 +1,18 @@
package util
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
}