@@ -184,32 +184,31 @@ func findCommand(config config.Config, name string) (*latest.CommandConfig, erro
184184 return config .Config ().Commands [name ], nil
185185}
186186
187- func executeCommandWithAfter (ctx context.Context , command * latest.CommandConfig , args []string , variables map [string ]interface {}, dir string , stdout io.Writer , stderr io.Writer , stdin io.Reader , log log.Logger ) ( err error ) {
188- err = interrupt .Global .Run (func () error {
187+ func executeCommandWithAfter (ctx context.Context , command * latest.CommandConfig , args []string , variables map [string ]interface {}, dir string , stdout io.Writer , stderr io.Writer , stdin io.Reader , log log.Logger ) error {
188+ originalErr : = interrupt .Global .Run (func () error {
189189 return ExecuteCommand (ctx , command , variables , args , dir , stdout , stderr , stdin )
190190 }, func () {
191191 if command .After != "" {
192192 vars := variables
193193 vars ["COMMAND_INTERRUPT" ] = "true"
194- err = executeShellCommand (ctx , command .After , vars , args , dir , stdout , stderr , stdin )
194+ err : = executeShellCommand (ctx , command .After , vars , args , dir , stdout , stderr , stdin )
195195 if err != nil {
196196 log .Errorf ("error executing after command: %v" , err )
197197 }
198198 }
199199 })
200200 if command .After != "" {
201201 vars := variables
202- if err != nil {
203- vars ["COMMAND_ERROR" ] = err .Error ()
204- log .Error (err )
202+ if originalErr != nil {
203+ vars ["COMMAND_ERROR" ] = originalErr .Error ()
205204 }
206- err = executeShellCommand (ctx , command .After , vars , args , dir , stdout , stderr , stdin )
205+ err : = executeShellCommand (ctx , command .After , vars , args , dir , stdout , stderr , stdin )
207206 if err != nil {
208207 return errors .Wrap (err , "error executing after command" )
209208 }
210- return nil
211209 }
212- return err
210+
211+ return originalErr
213212}
214213
215214func ParseArgs (cobraCmd * cobra.Command , globalFlags * flags.GlobalFlags , log log.Logger ) ([]string , error ) {
0 commit comments