Sha256: 90c152d6541dd35d2ff0f4908a17483992a8d64db421e2053f70b858cc0acac6

Contents?: true

Size: 635 Bytes

Versions: 1

Compression:

Stored size: 635 Bytes

Contents

# frozen_string_literal: true
require 'shellwords'

module Opal
  module CliRunners
    class Phantomjs
      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)
        phantomjs_command = [
          'phantomjs',
          SCRIPT_PATH.shellescape,
          *argv.map(&:shellescape)
        ].join(' ')

        IO.popen(phantomjs_command, 'w', out: output) do |io|
          io.write(code)
        end

        @exit_status = $?.exitstatus
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opal-0.11.0.rc1 lib/opal/cli_runners/phantomjs.rb