Module: Spoom::Context::Exec
- Included in:
- Spoom::Context
- Defined in:
- lib/spoom/context/exec.rb
Overview
Execution features for a context @requires_ancestor: 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
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/spoom/context/exec.rb', line 29 def exec(command, capture_err: true) Bundler.with_unbundled_env do opts = { chdir: absolute_path } #: Hash[Symbol, 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 |