Module: Yarnlock::JsExecutor

Defined in:
lib/yarnlock/js_executor.rb

Class Method Summary collapse

Class Method Details

.execute(script, stdin) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/yarnlock/js_executor.rb', line 5

def self.execute(script, stdin)
  IO.popen(script_path(script), 'r+') do |io|
    io.puts stdin
    io.close_write
    io.gets
  end
end

.script_path(script) ⇒ Object



13
14
15
# File 'lib/yarnlock/js_executor.rb', line 13

def self.script_path(script)
  "#{Yarnlock.config.node_path} #{Yarnlock.config.script_dir}/#{script}"
end