bin/envjsrb in smparkes-envjs-0.0.4 vs bin/envjsrb in smparkes-envjs-0.0.5
- old
+ new
@@ -1,8 +1,9 @@
#!/usr/bin/env ruby
require 'rubygems'
+require 'pathname'
begin
require 'johnson/tracemonkey'
require 'johnson/cli'
require 'envjs/runtime'
@@ -21,12 +22,17 @@
RUNTIME.load Envjs::ENVJS
if ARGV.length > 0
begin
- ARGV.each do |file|
- if file =~ /\.x?html?$/
- RUNTIME.evaluate("window.location = '#{file}'", file, 1)
+ ARGV.each_with_index do |file,i|
+ if file =~ /\.x?html?$/ || file =~ %r(^https?://)
+ if i > 0
+ RUNTIME.wait
+ RUNTIME.evaluate("window.location = 'about:blank'", "(comand line)", 1)
+ end
+ RUNTIME.wait
+ RUNTIME.evaluate("window.location = 'file://#{Pathname.new(file).realpath}'", file, 1)
else
RUNTIME.load file
end
end
rescue Johnson::Error => je