module ShellOut

Public Instance Methods

shell_out(cmd, options: {}) click to toggle source
# File lib/server_tools/support/shell_out.rb, line 5
def shell_out(cmd, options: {})
  opts = options.merge(live_stdout: STDOUT, live_stderr: STDERR)
  shellout = Mixlib::ShellOut.new(cmd, opts)
  puts cmd
  Bundler.with_clean_env do
    shellout.run_command
  end
  handle_errors(shellout)
end

Private Instance Methods

handle_errors(shellout) click to toggle source
# File lib/server_tools/support/shell_out.rb, line 17
def handle_errors(shellout)
  if shellout.error?
    STDERR.puts('Failure!')
    STDERR.puts("Exit code: #{shellout.exitstatus}")
    exit(shellout.exitstatus)
  end
end