lib/execjs/external_runtime.rb in execjs-1.2.11 vs lib/execjs/external_runtime.rb in execjs-1.2.12

- old
+ new

@@ -119,16 +119,15 @@ private def binary @binary ||= locate_binary end - def which_windows(name) - result = `#{shell_escape("#{ExecJS.root}/support/which.bat", name)}` - result.strip.split("\n").first - end + def locate_executable(cmd) + if ExecJS.windows? && File.extname(cmd) == "" + cmd << ".exe" + end - def which_unix(cmd) if File.executable? cmd cmd else path = ENV['PATH'].split(File::PATH_SEPARATOR).find { |p| File.executable? File.join(p, cmd) @@ -163,10 +162,10 @@ end def which(command) Array(command).find do |name| name, args = name.split(/\s+/, 2) - path = ExecJS.windows? ? which_windows(name) : which_unix(name) + path = locate_executable(name) next unless path args ? "#{path} #{args}" : path end