Skip to content

Commit 9a22684

Browse files
author
Alexander Abroskin
committed
recognize git root directory
1 parent afa40d6 commit 9a22684

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

cmd/root.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package cmd
33
import (
44
"log"
55
"os"
6+
"os/exec"
7+
"strings"
68
"path/filepath"
79

810
"github.com/logrusorgru/aurora"
@@ -106,7 +108,12 @@ func getRootPath() string {
106108
}
107109

108110
func setRootPath(path string) {
109-
rootPath, _ = filepath.Abs(path)
111+
// get absolute path to .git dir (project root)
112+
cmd := exec.Command("sh", "-c", "git rev-parse --show-toplevel")
113+
114+
outputBytes, err := cmd.CombinedOutput()
115+
check(err)
116+
rootPath = strings.TrimSpace(string(outputBytes))
110117
}
111118

112119
func getSourceDir() string {

0 commit comments

Comments
 (0)