feat: get root dir from git command
This commit is contained in:
		
							parent
							
								
									ac1555a57c
								
							
						
					
					
						commit
						0d546f7824
					
				
							
								
								
									
										18
									
								
								pkg/util/path.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								pkg/util/path.go
									
									
									
									
									
										Normal 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
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user