Skip to content

Commit

Permalink
fix: create links using original command names
Browse files Browse the repository at this point in the history
  • Loading branch information
suzuki-shunsuke committed Nov 2, 2024
1 parent 632c0da commit a7d6090
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
7 changes: 3 additions & 4 deletions pkg/controller/which/which.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,15 @@ func (c *Controller) findExecFileFromPkg(logE *logrus.Entry, registries map[stri
}

func (c *Controller) findExecFileFromFile(logE *logrus.Entry, exeName string, pkg *aqua.Package, pkgInfo *registry.PackageInfo, file *registry.File) (*FindResult, error) {
cmds := map[string]struct{}{}
cmds := map[string]struct{}{
file.Name: {},
}
for _, alias := range pkg.CommandAliases {
if file.Name != alias.Command {
continue
}
cmds[alias.Alias] = struct{}{}
}
if len(cmds) == 0 {
cmds[file.Name] = struct{}{}
}
if _, ok := cmds[exeName]; !ok {
return nil, nil //nolint:nilnil
}
Expand Down
7 changes: 3 additions & 4 deletions pkg/installpackage/check_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,14 @@ func (is *Installer) checkAndCopyFile(ctx context.Context, logE *logrus.Entry, p
return nil
}
logE.Info("copying an executable file")
exeNames := map[string]struct{}{}
exeNames := map[string]struct{}{
file.Name: {},
}
for _, alias := range pkg.Package.CommandAliases {
if alias.Command == file.Name {
exeNames[alias.Alias] = struct{}{}
}
}
if len(exeNames) == 0 {
exeNames[file.Name] = struct{}{}
}
for exeName := range exeNames {
if err := is.Copy(filepath.Join(is.copyDir, exeName), exePath); err != nil {
return err
Expand Down
7 changes: 3 additions & 4 deletions pkg/installpackage/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ func (is *Installer) createPackageLinks(logE *logrus.Entry, pkg *config.Package,

func (is *Installer) createFileLinks(logE *logrus.Entry, pkg *config.Package, file *registry.File, aquaProxyPathOnWindows string) bool {
failed := false
cmds := map[string]struct{}{}
cmds := map[string]struct{}{
file.Name: {},
}
for _, alias := range pkg.Package.CommandAliases {
if file.Name != alias.Command {
continue
Expand All @@ -65,9 +67,6 @@ func (is *Installer) createFileLinks(logE *logrus.Entry, pkg *config.Package, fi
}
cmds[alias.Alias] = struct{}{}
}
if len(cmds) == 0 {
cmds[file.Name] = struct{}{}
}
for cmd := range cmds {
if err := is.createCmdLink(logE, file, cmd, aquaProxyPathOnWindows); err != nil {
logerr.WithError(logE, err).Error("create a link to aqua-proxy")
Expand Down

0 comments on commit a7d6090

Please sign in to comment.