Skip to content

Commit

Permalink
recognize git root directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Abroskin committed Nov 16, 2019
1 parent afa40d6 commit 9a22684
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package cmd
import (
"log"
"os"
"os/exec"
"strings"
"path/filepath"

"github.com/logrusorgru/aurora"
Expand Down Expand Up @@ -106,7 +108,12 @@ func getRootPath() string {
}

func setRootPath(path string) {
rootPath, _ = filepath.Abs(path)
// get absolute path to .git dir (project root)
cmd := exec.Command("sh", "-c", "git rev-parse --show-toplevel")

outputBytes, err := cmd.CombinedOutput()
check(err)
rootPath = strings.TrimSpace(string(outputBytes))
}

func getSourceDir() string {
Expand Down

0 comments on commit 9a22684

Please sign in to comment.