Method: Coaster::Git#run_cmd

Defined in:
lib/coaster/git.rb

#run_cmd(path, command) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/coaster/git.rb', line 7

def run_cmd(path, command)
  puts "#{path}: #{command}"
  stdout, stderr, status = Open3.capture3(command, chdir: path)
  if status.success?
    puts "  ↳ success: #{stdout.split("\n").join("\n             ")}"
    stdout
  else
    raise "Error executing command\nPATH: #{path}\nCMD: #{command}\nSTDERR:\n  ↳ #{stderr.split("\n").join("\n    ")}\nSTDOUT:\n  ↳ #{stdout.split("\n").join("\n    ")}"
  end
end