Module: Spoom::Context::Exec
Overview
Execution features for a context
Instance Method Summary collapse
-
#exec(command, capture_err: true) ⇒ Object
Run a command in this context directory : (String command, ?capture_err: bool) -> ExecResult.
Instance Method Details
#exec(command, capture_err: true) ⇒ Object
Run a command in this context directory : (String command, ?capture_err: bool) -> ExecResult
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/spoom/context/exec.rb', line 32 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 |