class EmbeddedJs::Adaptors::CommandRunner

Attributes

io[R]

Public Class Methods

new(io: Open3) click to toggle source
# File lib/embedded_js/adaptors/command_runner.rb, line 8
def initialize(io: Open3)
  @io = io
end

Public Instance Methods

run(cmd, environment_variables = {}) click to toggle source
# File lib/embedded_js/adaptors/command_runner.rb, line 12
def run(cmd, environment_variables = {})
  io.popen3(
    environment_variables,
    "#{cmd} 2>&1"
  ) do |stdin, stdout, _stderr, wait_thread|
    stdin.close_write

    while line = stdout.gets
      puts line
    end

    puts wait_thread.value
  end
end