Skip to content

Commit

Permalink
app: allow to use relative path
Browse files Browse the repository at this point in the history
  • Loading branch information
z7zmey committed Oct 26, 2017
1 parent 5a241d8 commit f3f391c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"log"
"os"
"strings"

"github.com/yookoala/realpath"
)

type ArrayFlags []string
Expand Down Expand Up @@ -66,6 +68,11 @@ func ParseConfigFlags() {

flag.Parse()

setDefaultPath()
convertToRealPath()
}

func setDefaultPath() {
if len(Config.path) == 0 {
path, err := os.Getwd()
if err != nil {
Expand All @@ -75,3 +82,17 @@ func ParseConfigFlags() {
Config.path = ArrayFlags{path}
}
}

func convertToRealPath() {
for i, path := range Config.path {
real, err := realpath.Realpath(path)
checkErr(err)
Config.path[i] = real
}

for i, path := range Config.exclude {
real, err := realpath.Realpath(path)
checkErr(err)
Config.exclude[i] = real
}
}

0 comments on commit f3f391c

Please sign in to comment.