Skip to content

Commit 4f847e5

Browse files
Fix resolving project relative path
Path for .newtrc is resolved before project is created.
1 parent 69976cf commit 4f847e5

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

newt/newtutil/newtutil.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ package newtutil
2222
import (
2323
"fmt"
2424
"io/ioutil"
25+
"path/filepath"
2526
"strconv"
2627
"strings"
2728

@@ -178,12 +179,17 @@ func MakeTempRepoDir() (string, error) {
178179
}
179180

180181
func ProjRelPath(path string) string {
181-
if strings.HasPrefix(path, "/") {
182-
return path
182+
if filepath.IsAbs(path) {
183+
proj := interfaces.GetProject()
184+
if proj != nil {
185+
relPath, err := filepath.Rel(proj.Path(), path)
186+
if err == nil {
187+
path = relPath
188+
}
189+
}
183190
}
184191

185-
proj := interfaces.GetProject()
186-
return strings.TrimPrefix(path, proj.Path()+"/")
192+
return path
187193
}
188194

189195
func PrintNewtVersion() {

0 commit comments

Comments
 (0)