Method: ExecJS::ExternalRuntime::Context#exec

Defined in:
lib/j1/patches/rubygems/execjs-2.7.0/lib/execjs/external_runtime.rb

#exec(source, options = {}) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/j1/patches/rubygems/execjs-2.7.0/lib/execjs/external_runtime.rb', line 25

def exec(source, options = {})
  source = encode(source)
  source = "#{@source}\n#{source}" if @source != ""
  source = @runtime.compile_source(source)

  tmpfile = write_to_tempfile(source)

  if ExecJS.cygwin?
    filepath = `cygpath -m #{tmpfile.path}`.rstrip
  else
    filepath = tmpfile.path
  end

  begin
    extract_result(@runtime.exec_runtime(filepath), filepath)
  ensure
    File.unlink(tmpfile)
  end
end