Skip to content

Commit

Permalink
fix: fix the relative path
Browse files Browse the repository at this point in the history
  • Loading branch information
suzuki-shunsuke committed Sep 28, 2024
1 parent 9b7f2f1 commit 39523e2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/config/registry/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type File struct {
Name string `validate:"required" json:"name,omitempty" yaml:",omitempty"`
Src string `json:"src,omitempty" yaml:",omitempty"`
Dir string `json:"dir,omitempty" yaml:",omitempty"`
// Link is the relative path from Src to the link
Link string `json:"link,omitempty" yaml:",omitempty"`
}

Expand Down
9 changes: 8 additions & 1 deletion pkg/installpackage/check_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,14 @@ func (is *Installer) checkFileSrc(ctx context.Context, logE *logrus.Entry, pkg *
return exePath, nil
}

if err := is.createLink(logE, filepath.Join(filepath.Dir(fileSrc), file.Link), file.Link); err != nil {
// file.Link is the relative path from exePath to the link
link := filepath.Join(filepath.Dir(exePath), file.Link)
dest, err := filepath.Rel(filepath.Dir(link), exePath)
if err != nil {
return "", err

Check failure on line 140 in pkg/installpackage/check_file.go

View workflow job for this annotation

GitHub Actions / test / test

error returned from external package is unwrapped: sig: func path/filepath.Rel(basepath string, targpath string) (string, error) (wrapcheck)
}

if err := is.createLink(logE, link, dest); err != nil {
return "", fmt.Errorf("create the symbolic link: %w", err)
}

Expand Down

0 comments on commit 39523e2

Please sign in to comment.