Method: GitReflow::Sandbox#run

Defined in:
lib/git_reflow/sandbox.rb

#run(command, options = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/git_reflow/sandbox.rb', line 23

def run(command, options = {})
  options = { loud: true, blocking: true, raise: false }.merge(options)

  GitReflow.logger.debug "Running... #{command}"

  if options[:with_system] == true
    system(command)
  else
    output = %x{#{command}}

    if !$?.success?
      raise CommandError.new(output, "\"#{command}\" failed to run.") if options[:raise] == true
      abort "\"#{command}\" failed to run." if options[:blocking] == true
    end

    puts output if options[:loud] == true
    output
  end
end