Skip to content

Commit

Permalink
add ability to read symlink basedirs
Browse files Browse the repository at this point in the history
  • Loading branch information
klnusbaum committed May 22, 2016
1 parent d9640dc commit 52f7192
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions dependency/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@ func NewResolver(basedir string) (*Resolver, error) {
if err != nil {
return nil, err
}

basedir, err = checkForBasedirSymlink(basedir)

if err != nil {
return nil, err
}

vdir := filepath.Join(basedir, "vendor")

buildContext, err := util.GetBuildContext()
Expand Down Expand Up @@ -940,3 +947,20 @@ func srcDir(fi os.FileInfo) bool {

return true
}

// checkForBasedirSymlink checks to see if the given basedir is actually a
// symlink. In the case that it is a symlink, the symlink is read and returned.
// If the basedir is not a symlink, the provided basedir argument is simply
// returned back to the caller.
func checkForBasedirSymlink(basedir string) (string, error) {
fi, err := os.Lstat(basedir)
if err != nil {
return "", err
}

if fi.Mode()&os.ModeSymlink != 0 {
return os.Readlink(basedir)
}

return basedir, nil
}

0 comments on commit 52f7192

Please sign in to comment.