Class: Opal::CliRunners::Gjs

Inherits:
Object
  • Object
show all
Defined in:
opal/lib/opal/cli_runners/gjs.rb

Overview

Gjs is GNOME's JavaScript runtime based on Mozilla SpiderMonkey

Defined Under Namespace

Classes: MissingGjs

Class Method Summary collapse

Class Method Details

.call(data) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'opal/lib/opal/cli_runners/gjs.rb', line 11

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