diff --git a/pkg/controller/cp/controller.go b/pkg/controller/cp/controller.go index c01ba993c..fd230dfd4 100644 --- a/pkg/controller/cp/controller.go +++ b/pkg/controller/cp/controller.go @@ -133,7 +133,7 @@ func (c *Controller) installAndCopy(ctx context.Context, logE *logrus.Entry, par } } - if err := c.copy(logE, param, findResult, exeName); err != nil { + if err := c.copy(logE, param, findResult.ExePath, exeName); err != nil { return err } return nil diff --git a/pkg/controller/cp/copy.go b/pkg/controller/cp/copy.go index 4654af9f6..d9bf90ab1 100644 --- a/pkg/controller/cp/copy.go +++ b/pkg/controller/cp/copy.go @@ -5,11 +5,10 @@ import ( "path/filepath" "github.com/aquaproj/aqua/v2/pkg/config" - "github.com/aquaproj/aqua/v2/pkg/controller/which" "github.com/sirupsen/logrus" ) -func (c *Controller) copy(logE *logrus.Entry, param *config.Param, findResult *which.FindResult, exeName string) error { +func (c *Controller) copy(logE *logrus.Entry, param *config.Param, exePath string, exeName string) error { p := filepath.Join(param.Dest, exeName) if c.runtime.GOOS == "windows" && filepath.Ext(exeName) == "" { p += ".exe" @@ -18,7 +17,7 @@ func (c *Controller) copy(logE *logrus.Entry, param *config.Param, findResult *w "exe_name": exeName, "dest": p, }).Info("coping a file") - if err := c.packageInstaller.Copy(p, findResult.ExePath); err != nil { + if err := c.packageInstaller.Copy(p, exePath); err != nil { return fmt.Errorf("copy a file: %w", err) } return nil diff --git a/pkg/installpackage/check_file.go b/pkg/installpackage/check_file.go index 70868fc68..0c887a66d 100644 --- a/pkg/installpackage/check_file.go +++ b/pkg/installpackage/check_file.go @@ -59,10 +59,20 @@ func (is *Installer) checkAndCopyFile(ctx context.Context, logE *logrus.Entry, p return nil } logE.Info("copying an executable file") - if err := is.Copy(filepath.Join(is.copyDir, file.Name), exePath); err != nil { - return err + exeNames := map[string]struct{}{} + 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 + } } - return nil }