Class: Gemchain::Executor::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/gemchain/executor.rb

Overview

Real command runner: executes via Open3, raises ExecutionError with output context on any non-zero exit.

Instance Method Summary collapse

Instance Method Details

#run(command, chdir: nil) ⇒ Object

Raises:



18
19
20
21
22
23
24
25
# File 'lib/gemchain/executor.rb', line 18

def run(command, chdir: nil)
  out, err, status = Open3.capture3(*command, chdir: chdir)
  return if status.success?

  detail = err.lines.first(5).join.strip
  detail = out.lines.first(5).join.strip if detail.empty?
  raise ExecutionError, "Command failed: #{command.join(' ')}#{detail.empty? ? '' : "\n#{detail}"}"
end