Module: CommandRunner

Defined in:
lib/roqua/support/command_runner.rb

Class Method Summary collapse

Class Method Details

.run_command_and_print(cmd, output) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 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