diff --git a/lib/execjs/external_runtime.rb b/lib/execjs/external_runtime.rb index 50515ac..04ba042 100644 --- a/lib/execjs/external_runtime.rb +++ b/lib/execjs/external_runtime.rb @@ -6,6 +6,8 @@ module ExecJS def initialize(options) @command = options[:command] @runner_path = options[:runner_path] + @test_args = options[:test_args] + @test_match = options[:test_match] end def eval(source) @@ -22,8 +24,15 @@ module ExecJS def available? command = @command.split(/\s+/).first - `which #{command}` - $? == 0 + binary = `which #{command}` + if $? == 0 + if @test_args + output = "#{binary} #{@test_args} 2>&1" + output.match(@test_match) + else + true + end + end end protected diff --git a/lib/execjs/runtimes.rb b/lib/execjs/runtimes.rb index dae435c..b68cf2d 100644 --- a/lib/execjs/runtimes.rb +++ b/lib/execjs/runtimes.rb @@ -20,6 +20,8 @@ module ExecJS define_runtime :V8, :command => "v8", + :test_args => "--help", + :test_match => /--crankshaft/, :runner_path => runner_path("basic.js") define_runtime :Node,