class Verto::SystemCommandExecutor

Constants

Error
Result

Public Instance Methods

run(command) click to toggle source
# File lib/verto/utils/system_command_executor.rb, line 20
def run(command)
  stderr&.puts running_log(command, path)

  Open3.popen3(command, chdir: path.to_s) do |_, stdout, stderr, wait_thread|
    @output = stdout.read
    @error = stderr.read
    @result = wait_thread.value
  end

  stdout << @output if stdout
  stderr << @error if stderr

  Result.new(@output, @error, @result)
end
run!(command) click to toggle source
# File lib/verto/utils/system_command_executor.rb, line 35
def run!(command)
  result = run(command)

  raise Error, @error unless @error.empty?

  result
end

Private Instance Methods

running_log(command, path) click to toggle source
# File lib/verto/utils/system_command_executor.rb, line 45
def running_log(command, path)
  log = "Running: #{command}"
  log = "#{log} (in #{path})" if path != './'
  log
end