Skip to content

Commit

Permalink
fix(remove): ignore not found commands
Browse files Browse the repository at this point in the history
  • Loading branch information
suzuki-shunsuke committed Sep 28, 2024
1 parent 1587e3d commit 40f76a6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions pkg/controller/remove/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/aquaproj/aqua/v2/pkg/config"
"github.com/aquaproj/aqua/v2/pkg/config/aqua"
"github.com/aquaproj/aqua/v2/pkg/config/registry"
"github.com/aquaproj/aqua/v2/pkg/controller/which"
"github.com/aquaproj/aqua/v2/pkg/fuzzyfinder"
"github.com/sirupsen/logrus"
"github.com/spf13/afero"
Expand Down Expand Up @@ -161,6 +162,10 @@ func (c *Controller) removeCommands(ctx context.Context, logE *logrus.Entry, par
logE := logE.WithField("exe_name", cmd)
findResult, err := c.which.Which(ctx, logE, param, cmd)
if err != nil {
if errors.Is(err, which.ErrCommandIsNotFound) {
logE.Debug("the command isn't found")
continue
}
return fmt.Errorf("find a command: %w", err)
}
if findResult.Package == nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/which/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ package which
import "errors"

var (
errCommandIsNotFound = errors.New("command is not found")
ErrCommandIsNotFound = errors.New("command is not found")
errVersionIsRequired = errors.New("version is required")
)
2 changes: 1 addition & 1 deletion pkg/controller/which/which.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (c *Controller) Which(ctx context.Context, logE *logrus.Entry, param *confi
ExePath: exePath,
}, nil
}
return nil, logerr.WithFields(errCommandIsNotFound, logrus.Fields{ //nolint:wrapcheck
return nil, logerr.WithFields(ErrCommandIsNotFound, logrus.Fields{ //nolint:wrapcheck
"exe_name": exeName,
"doc": "https://aquaproj.github.io/docs/reference/codes/004",
})
Expand Down

0 comments on commit 40f76a6

Please sign in to comment.