class Guac::SysCommand

Public Class Methods

run(dir, commands = []) click to toggle source
# File lib/guac/sys_command.rb, line 8
def run(dir, commands = [])
  stdin, stdout, stderr, wait_thr = Open3.popen3(*commands, chdir: dir)
  output = stdout.gets(nil)
  error = stderr.gets(nil)
  exit_status = wait_thr.value

  stdout.close
  stderr.close

  if output.nil? && error
    raise SysCommandError, error
  end

  output
end