@@ -589,6 +589,17 @@ def to_cmd_str(cmd):
589589 work_dir = work_dir , out_file = cmd_out_fp , err_file = cmd_err_fp , cmd_sh = cmd_sh ,
590590 thread_id = thread_id , task_id = task_id )
591591
592+ if with_hooks :
593+ run_hook_kwargs = {
594+ 'exit_code' : res .exit_code ,
595+ 'interactive' : interactive ,
596+ 'output' : res .output ,
597+ 'stderr' : res .stderr ,
598+ 'work_dir' : res .work_dir ,
599+ 'shell_cmd_result' : res ,
600+ }
601+ run_hook (RUN_SHELL_CMD , hooks , post_step_hook = True , args = [cmd ], kwargs = run_hook_kwargs )
602+
592603 # always log command output
593604 cmd_name = cmd_str .split (' ' )[0 ]
594605 if split_stderr :
@@ -618,16 +629,6 @@ def to_cmd_str(cmd):
618629 except OSError as err :
619630 raise EasyBuildError (f"Failed to return to { initial_work_dir } after executing command `{ cmd_str } `: { err } " )
620631
621- if with_hooks :
622- run_hook_kwargs = {
623- 'exit_code' : res .exit_code ,
624- 'interactive' : interactive ,
625- 'output' : res .output ,
626- 'stderr' : res .stderr ,
627- 'work_dir' : res .work_dir ,
628- }
629- run_hook (RUN_SHELL_CMD , hooks , post_step_hook = True , args = [cmd ], kwargs = run_hook_kwargs )
630-
631632 if not hidden :
632633 time_since_start = time_str_since (start_time )
633634 trace_msg (f"command completed: exit { res .exit_code } , ran in { time_since_start } " )
0 commit comments