diff --git a/cmd/check.go b/cmd/check.go index f1b74f4f76..c994b21dad 100644 --- a/cmd/check.go +++ b/cmd/check.go @@ -21,10 +21,10 @@ func setupCheckCommand() *cobraext.Command { Short: "Check the package", Long: checkLongDescription, RunE: func(cmd *cobra.Command, args []string) error { - err := cobraext.ComposeCommandActions(cmd, args, - formatCommandAction, - lintCommandAction, - buildCommandAction, + err := cobraext.ComposeCommands(args, + setupFormatCommand(), + setupLintCommand(), + setupBuildCommand(), ) if err != nil { return errors.Wrap(err, "checking package failed") diff --git a/internal/cobraext/action.go b/internal/cobraext/action.go index 46f20afa4d..47d877e066 100644 --- a/internal/cobraext/action.go +++ b/internal/cobraext/action.go @@ -21,3 +21,14 @@ func ComposeCommandActions(cmd *cobra.Command, args []string, actions ...Command } return nil } + +// ComposeCommands runs given commands in order +func ComposeCommands(args []string, composed ...*Command) error { + for _, cmd := range composed { + err := cmd.RunE(cmd.Command, args) + if err != nil { + return err + } + } + return nil +}