From 5d0d51b6badb1ce5d23bb4a2b9c2d7d9e7104e54 Mon Sep 17 00:00:00 2001 From: Sam Stephenson Date: Sun, 6 Feb 2011 21:50:03 -0600 Subject: [PATCH] therubyracer gem installs an incompatible `v8` binary - make sure we don't use it --- lib/execjs/external_runtime.rb | 13 +++++++++++-- lib/execjs/runtimes.rb | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-) 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,