lib/hookit/resource/execute.rb in hookit-0.8.0 vs lib/hookit/resource/execute.rb in hookit-0.9.0

- old
+ new

@@ -11,10 +11,11 @@ field :path field :returns field :timeout field :stream field :on_data + field :on_exit field :validator field :ignore_exit actions :run default_action :run @@ -53,11 +54,15 @@ def run! Timeout::timeout(timeout) do res = `#{cmd}` code = $?.exitstatus - unexpected_exit(code) unless code == returns + if on_exit and on_exit.respond_to? :call + on_exit.call(code) + else + unexpected_exit(code) unless code == returns + end validate! res end end def stream! @@ -79,10 +84,15 @@ result << chunk.to_s end end code = $?.exitstatus - unexpected_exit(code) unless code == returns + + if on_exit and on_exit.respond_to? :call + on_exit.call(code) + else + unexpected_exit(code) unless code == returns + end validate! result end def cmd \ No newline at end of file