Skip to content

Commit

Permalink
Fix cli.rb to report errors occuring inside node
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Oct 6, 2013
1 parent bdc894e commit f2e43d8
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions lib/opal/cli.rb
Expand Up @@ -88,7 +88,7 @@ def prepare_eval_code
def run_code
begin
full_source = sprockets[filename]
rescue Sprockets::FileOutsidePaths => e
rescue Sprockets::FileOutsidePaths
@server = nil
full_path = File.expand_path(filename)
load_paths << File.dirname(full_path)
Expand All @@ -97,16 +97,15 @@ def run_code
end

require 'open3'
stdin, stdout, stderr = Open3.popen3('node')

# out, err, status = Open3.capture3('node', :stdin_data => full_source)
i, o, e = Open3.popen3('node')
i.write full_source
i.close
output_text = o.read
status = $?
stdin.write full_source
stdin.close

raise "Errored: #{e}" if status != 0
puts output_text
[stdout, stderr].each do |io|
str = io.read
puts str unless str.empty?
end

rescue Errno::ENOENT
$stderr.puts 'Please install Node.js to be able to run Opal scripts.'
Expand Down

0 comments on commit f2e43d8

Please sign in to comment.