Skip to content

Commit 4f46884

Browse files
committedSep 17, 2014
Workaround JVM suprocess api limitations
(see comment in code)
1 parent a5cde6b commit 4f46884

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed
 

‎lib/opal/cli_runners/nodejs.rb

+14-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,20 @@ def system_with_output(env, *cmd)
3232
io_output = IO.try_convert(output)
3333
return system(env,*cmd) if io_output
3434

35-
require 'open3'
36-
captured_output, status = Open3.capture2(env,*cmd)
35+
if RUBY_PLATFORM == 'java'
36+
# JRuby has issues in dealing with subprocesses (at least up to 1.7.15)
37+
# @headius told me it's mostly fixed on master, but while we wait for it
38+
# to ship here's a tempfile workaround.
39+
require 'tempfile'
40+
require 'shellwords'
41+
tempfile = Tempfile.new('opal-node-output')
42+
system(env,cmd.shelljoin+" > #{tempfile.path}")
43+
captured_output = File.read tempfile.path
44+
tempfile.close
45+
else
46+
require 'open3'
47+
captured_output, status = Open3.capture2(env,*cmd)
48+
end
3749
output.write captured_output
3850
end
3951

0 commit comments

Comments
 (0)
Please sign in to comment.