Method: Minke::Helpers::Shell#execute

Defined in:
lib/minke/helpers/shell.rb

#execute(command) ⇒ Object

Executes a shell command and returns the return status



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/minke/helpers/shell.rb', line 10

def execute command
  @logger.debug command
  
  Open3.popen2e(command) do |stdin, stdout_err, wait_thr|
    while line = stdout_err.gets
      @logger.debug line
    end
    
    exit_status = wait_thr.value
    unless exit_status.success?
      raise "Error executing command: #{command}"
    end
  end
end