Sha256: 4f5a05373636abb981438c1dfe379ce51ca6ab687f1208406ec8574c51c325ed

Contents?: true

Size: 762 Bytes

Versions: 16

Compression:

Stored size: 762 Bytes

Contents

# frozen_string_literal: true

require 'opal/paths'
require 'opal/cli_runners/system_runner'
require 'shellwords'

module Opal
  module CliRunners
    # Gjs is GNOME's JavaScript runtime based on Mozilla SpiderMonkey
    class Gjs
      def self.call(data)
        exe = ENV['GJS_PATH'] || 'gjs'
        builder = data[:builder].call

        opts = Shellwords.shellwords(ENV['GJS_OPTS'] || '')
        opts.unshift('-m') if builder.esm?

        SystemRunner.call(data.merge(builder: -> { builder })) do |tempfile|
          [exe, *opts, tempfile.path, *data[:argv]]
        end
      rescue Errno::ENOENT
        raise MissingGjs, 'Please install Gjs to be able to run Opal scripts.'
      end

      class MissingGjs < RunnerError
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
opal-1.8.3.rc1 lib/opal/cli_runners/gjs.rb
opal-1.8.2 lib/opal/cli_runners/gjs.rb
opal-1.8.1 lib/opal/cli_runners/gjs.rb
opal-1.8.0 lib/opal/cli_runners/gjs.rb
opal-1.8.0.beta1 lib/opal/cli_runners/gjs.rb
opal-1.7.4 lib/opal/cli_runners/gjs.rb
opal-1.8.0.alpha1 lib/opal/cli_runners/gjs.rb
opal-1.7.3 lib/opal/cli_runners/gjs.rb
opal-1.7.2 lib/opal/cli_runners/gjs.rb
opal-1.7.1 lib/opal/cli_runners/gjs.rb
opal-1.7.0 lib/opal/cli_runners/gjs.rb
opal-1.7.0.rc1 lib/opal/cli_runners/gjs.rb
opal-1.6.1 lib/opal/cli_runners/gjs.rb
opal-1.6.0 lib/opal/cli_runners/gjs.rb
opal-1.6.0.rc1 lib/opal/cli_runners/gjs.rb
opal-1.6.0.alpha1 lib/opal/cli_runners/gjs.rb