Module: Spoom::Context::Exec
Overview
Execution features for a context
Instance Method Summary collapse
Instance Method Details
#exec(command, capture_err: true) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/spoom/context/exec.rb', line 35 def exec(command, capture_err: true) Bundler.with_unbundled_env do opts = T.let({ chdir: absolute_path }, T::Hash[Symbol, T.untyped]) if capture_err out, err, status = Open3.capture3(command, opts) ExecResult.new(out: out, err: err, status: T.must(status.success?), exit_code: T.must(status.exitstatus)) else out, status = Open3.capture2(command, opts) ExecResult.new(out: out, err: nil, status: T.must(status.success?), exit_code: T.must(status.exitstatus)) end end end |