Sha256: ef65bd7e3461b6406c94e92e3906f829cec7bece60a17b40bf804f14708c1b84

Contents?: true

Size: 871 Bytes

Versions: 7

Compression:

Stored size: 871 Bytes

Contents

# frozen_string_literal: true

module Wasmify
  module Rails
    # A wrapper for the wasmtime CLI used to
    # verify compiled modules.
    module Wasmtimer
      class << self
        def run(wasm_path, script)
          return unless wasmtime_installed?

          exec(%Q(wasmtime run --dir ./storage::/rails/storage #{wasm_path} -W0 -r/bundle/setup -e '#{script}'))
        end

        private

        def wasmtime_installed?
          unless system("which wasmtime > /dev/null 2>&1")
            $stderr.puts "Wasmtime is required to verify Wasm builds.\nPlease see installations instructions at https://wasmtime.dev."
            if RUBY_PLATFORM =~ /darwin/
              $stderr.puts "You can also install it via Homebrew:\n  brew install wasmtime"
            end
            return false
          end

          true
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
wasmify-rails-0.2.0 lib/wasmify/rails/wasmtimer.rb
wasmify-rails-0.1.5 lib/wasmify/rails/wasmtimer.rb
wasmify-rails-0.1.4 lib/wasmify/rails/wasmtimer.rb
wasmify-rails-0.1.3 lib/wasmify/rails/wasmtimer.rb
wasmify-rails-0.1.2 lib/wasmify/rails/wasmtimer.rb
wasmify-rails-0.1.1 lib/wasmify/rails/wasmtimer.rb
wasmify-rails-0.1.0 lib/wasmify/rails/wasmtimer.rb