Skip to content

Commit

Permalink
Support opening repl with an existing ruby file
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Oct 18, 2013
1 parent 6b71bae commit e3e1ccc
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions bin/opal-repl
Expand Up @@ -8,7 +8,7 @@ module Opal
@builder = Opal::Builder.new
end

def run
def run(filename = nil)
return if @v8

begin
Expand All @@ -21,6 +21,14 @@ module Opal
@v8['console'] = self
@v8.eval @builder.build 'opal'

if filename
if File.exist? filename
eval_ruby File.read(filename)
else
fail "file does not exist: #{filename}"
end
end

run_repl
end

Expand Down Expand Up @@ -60,4 +68,4 @@ module Opal
end
end

Opal::V8Context.new.run
Opal::V8Context.new.run ARGV.first

0 comments on commit e3e1ccc

Please sign in to comment.