Module: Execution

Included in:
GitWorkflow::Commands::Base, GitWorkflow::Git::Repository
Defined in:
lib/git_workflow/core_ext.rb

Defined Under Namespace

Classes: CommandFailure

Instance Method Summary collapse

Instance Method Details

#execute_command(command) ⇒ Object



60
61
62
63
64
# File 'lib/git_workflow/core_ext.rb', line 60

def execute_command(command)
  command_output = nil
  execute_command_with_output_handling(command) { |stdout, _, _| command_output = stdout.read }
  command_output
end

#execute_command_with_output_handling(command, &block) ⇒ Object



66
67
68
69
70
71
72
73
# File 'lib/git_workflow/core_ext.rb', line 66

def execute_command_with_output_handling(command, &block)
  debug("Executing '#{ command }' ...") do
    exit_status = POpen4.popen4(command) do |stdout, stderr, stdin, pid|
      yield(stdout, stderr, stdin)
    end
    CommandFailure.new(command, exit_status).raise_if_required!
  end
end