Permalink
Browse files

shell out to find the binary when absolutely necessary

  • Loading branch information...
tenderlove committed Dec 5, 2011
1 parent 1c0af50 commit dc5951baa67a70e29d16a53e5d060b05b58827a5
Showing with 8 additions and 3 deletions.
  1. +8 −3 lib/execjs/external_runtime.rb
@@ -94,7 +94,7 @@ def initialize(options)
@test_args = options[:test_args]
@test_match = options[:test_match]
@encoding = options[:encoding]
- @binary = locate_binary
+ @binary = nil
end
def exec(source)
@@ -113,16 +113,21 @@ def compile(source)
def available?
require "multi_json"
- @binary ? true : false
+ binary ? true : false
end
+ private
+ def binary
+ @binary ||= locate_binary
+ end
+
protected
def runner_source
@runner_source ||= IO.read(@runner_path)
end
def exec_runtime(filename)
- output = sh("#{shell_escape(*(@binary.split(' ') << filename))} 2>&1")
+ output = sh("#{shell_escape(*(binary.split(' ') << filename))} 2>&1")
if $?.success?
output
else

0 comments on commit dc5951b

Please sign in to comment.