From 0ef664e93d0db38260d3e13f22563b902c5f969c Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Tue, 23 Dec 2014 00:22:53 -0600 Subject: [PATCH] Always redirect stderr in jruby --- lib/execjs/external_runtime.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/execjs/external_runtime.rb b/lib/execjs/external_runtime.rb index f123cfe..bd51eae 100644 --- a/lib/execjs/external_runtime.rb +++ b/lib/execjs/external_runtime.rb @@ -169,6 +169,21 @@ module ExecJS arg }.join(" ") end + elsif RUBY_ENGINE == 'jruby' + require 'shellwords' + + def exec_runtime(filename) + command = "#{Shellwords.join(binary.split(' ') << filename)} 2>&1" + io = IO.popen(command, @popen_options) + output = io.read + io.close + + if $?.success? + output + else + raise RuntimeError, output + end + end else def exec_runtime(filename) io = IO.popen(binary.split(' ') << filename, @popen_options.merge({err: [:child, :out]}))