@@ -75,24 +75,22 @@ defimpl GitHooks.Task, for: GitHooks.Tasks.Mix do
75
75
Map . put ( mix_task , :result , result )
76
76
end
77
77
78
- # Mix tasks always raise an error if they are not success, at the moment does
79
- # not seems that handling the result is needed. Also, handling the result to
80
- # check the success of a task is almost impossible, as it will depend on each
81
- # implementation.
82
- #
83
- # XXX Since tests runs on the command, if they fail then this task is
84
- # considered failed.
85
- def success? ( % MixTask { result: 1 } ) , do: false
86
- def success? ( % MixTask { result: _ } ) , do: true
87
-
88
- def print_result ( % MixTask { task: task , result: 1 } = mix_task ) do
89
- Printer . error ( "`#{ task } ` failed" )
78
+ # Mix tasks raise an error if they are valid, but determining if they are
79
+ # success or not depends on the return of the task.
80
+ @ success_results [ 0 , :ok , nil ]
81
+
82
+ def success? ( % MixTask { result: result } ) when result in @ success_results , do: true
83
+ def success? ( % MixTask { result: _ } ) , do: false
84
+
85
+ def print_result ( % MixTask { task: task , result: result } = mix_task )
86
+ when result in @ success_results do
87
+ Printer . success ( "`#{ task } ` was successful" )
90
88
91
89
mix_task
92
90
end
93
91
94
- def print_result ( % MixTask { task: task , result: _ } = mix_task ) do
95
- Printer . success ( " `#{ task } ` was successful ")
92
+ def print_result ( % MixTask { task: task , result: result } = mix_task ) do
93
+ Printer . error ( "mix task `#{ task } ` failed, return result: #{ inspect ( result ) } ")
96
94
97
95
mix_task
98
96
end
0 commit comments