lib/opal/cli_runners/phantomjs.rb in opal-0.9.4 vs lib/opal/cli_runners/phantomjs.rb in opal-0.10.0.beta1

- old
+ new

@@ -1,28 +1,28 @@ require 'shellwords' module Opal module CliRunners class Phantomjs - def initialize(output = $stdout) - @output = output + SCRIPT_PATH = File.expand_path('../phantom.js', __FILE__) + + def initialize(options) + @output = options.fetch(:output, $stdout) end attr_reader :output, :exit_status def run(code, argv) - unless argv.empty? - raise ArgumentError, 'Program arguments are not supported on the PhantomJS runner' - end + command = [ + 'phantomjs', + SCRIPT_PATH.shellescape, + *argv.map(&:shellescape) + ].join(' ') phantomjs = IO.popen(command, 'w', out: output) do |io| io.write(code) end - @exit_status = $?.exitstatus - end - def command - script_path = File.expand_path('../phantom.js', __FILE__) - "phantomjs #{script_path.shellescape}" + @exit_status = $?.exitstatus end end end end