Merge pull request #104 from rollandf/rel-path-link

Create link for local dependencies as relative links
This commit is contained in:
Frederic Branczyk 2020-05-06 21:03:31 +02:00 committed by GitHub
commit f581370e63
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -43,6 +43,11 @@ func (p *LocalPackage) Install(ctx context.Context, name, dir, version string) (
oldname := filepath.Join(wd, p.Source.Directory) oldname := filepath.Join(wd, p.Source.Directory)
newname := filepath.Join(dir, name) newname := filepath.Join(dir, name)
linkname, err := filepath.Rel(dir, oldname)
if err != nil {
linkname = oldname
}
err = os.RemoveAll(newname) err = os.RemoveAll(newname)
if err != nil { if err != nil {
@ -54,7 +59,7 @@ func (p *LocalPackage) Install(ctx context.Context, name, dir, version string) (
return "", errors.Wrap(err, "symlink destination path does not exist: %w") return "", errors.Wrap(err, "symlink destination path does not exist: %w")
} }
err = os.Symlink(oldname, newname) err = os.Symlink(linkname, newname)
if err != nil { if err != nil {
return "", errors.Wrap(err, "failed to create symlink for local dependency: %w") return "", errors.Wrap(err, "failed to create symlink for local dependency: %w")
} }