module CommandRunner

Public Class Methods

run_command_and_print(cmd, output) click to toggle source
# File lib/roqua/support/command_runner.rb, line 4
def self.run_command_and_print(cmd, output)
  output.puts "Executing #{cmd}\n\n"

  PTY.spawn(cmd) do |read_stream, write_stream, pid|
    begin
      while chars = read_stream.read(1)
        output.print chars
      end
    rescue Errno::EIO
    end
    Process.wait(pid)
  end
  output.puts "\n\n\n"

  if $?
    exit 1 if $?.exitstatus > 0
  else
    raise "Huh?! We didn't get an exit status from that last one: #{cmd}"
  end
end