module Gouteur::Shell

thin wrapper for Open3

Public Instance Methods

run(args, pwd: Dir.pwd, env: {}) click to toggle source
# File lib/gouteur/shell.rb, line 8
def run(args, pwd: Dir.pwd, env: {})
  stdout, stderr, status = begin
    Bundler.with_original_env { Open3.capture3(env, *args, chdir: pwd) }
  rescue Errno::ENOENT => e
    # bring errors such as "command not found: bundle" into the same form
    ['', e.message, $?]
  end

  Result.new(
    args: args, pwd: pwd, stdout: stdout, stderr: stderr, status: status
  )
end
run!(args, pwd: Dir.pwd, env: {}) click to toggle source
# File lib/gouteur/shell.rb, line 21
def run!(args, pwd: Dir.pwd, env: {})
  result = run(args, pwd: pwd, env: env)
  result.success? || raise(Error, result.full_error)
  result
end