@@ -14,6 +14,12 @@ import (
1414 "github.com/jzero-io/jzero/cmd/jzero/internal/pkg/execx"
1515)
1616
17+ var (
18+ runOutputFn = execx .RunOutput
19+ printHookCommandFn = printHookCommand
20+ printHookOutputFn = printHookOutput
21+ )
22+
1723func Run (cmd * cobra.Command , hookAction , hooksName string , hooks []string ) error {
1824 wd , _ := os .Getwd ()
1925
@@ -51,10 +57,10 @@ func Run(cmd *cobra.Command, hookAction, hooksName string, hooks []string) error
5157 }
5258
5359 for _ , v := range hooks {
54- output , err := execx .RunOutput (v , wd , "JZERO_HOOK_TRIGGERED=true" )
5560 if ! quiet {
56- printHookCommand ( v , err == nil )
61+ printHookCommandFn ( v )
5762 }
63+ output , err := runOutputFn (v , wd , "JZERO_HOOK_TRIGGERED=true" )
5864 if err != nil {
5965 lines := console .NormalizeErrorLines (output )
6066 if len (lines ) == 0 {
@@ -74,7 +80,7 @@ func Run(cmd *cobra.Command, hookAction, hooksName string, hooks []string) error
7480 return console .MarkRenderedError (err )
7581 }
7682 if ! quiet && output != "" {
77- printHookOutput (output )
83+ printHookOutputFn (output )
7884 }
7985 }
8086
@@ -121,14 +127,10 @@ func Run(cmd *cobra.Command, hookAction, hooksName string, hooks []string) error
121127 return nil
122128}
123129
124- func printHookCommand (command string , success bool ) {
130+ func printHookCommand (command string ) {
125131 if strings .Contains (command , "\n " ) {
126132 lines := strings .Split (command , "\n " )
127- if success {
128- fmt .Printf ("%s\n " , console .BoxItem (console .Cyan ("Executing" )))
129- } else {
130- fmt .Printf ("%s\n " , console .BoxErrorItem (console .Cyan ("Executing" )))
131- }
133+ fmt .Printf ("%s\n " , console .BoxInfoItem (console .Cyan ("Executing" )))
132134 for _ , line := range lines {
133135 trimmedLine := strings .TrimSpace (line )
134136 if trimmedLine != "" {
@@ -139,12 +141,7 @@ func printHookCommand(command string, success bool) {
139141 }
140142
141143 item := fmt .Sprintf ("%s %s" , console .Cyan ("Executing" ), command )
142- if success {
143- fmt .Printf ("%s\n " , console .BoxItem (item ))
144- return
145- }
146-
147- fmt .Printf ("%s\n " , console .BoxErrorItem (item ))
144+ fmt .Printf ("%s\n " , console .BoxInfoItem (item ))
148145}
149146
150147func printHookOutput (output string ) {
0 commit comments