Class: Guac::SysCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/guac/sys_command.rb

Class Method Summary collapse

Class Method Details

.run(dir, commands = []) ⇒ Object



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