Sha256: 6d7552c95337c2f5bc931c4fecf1891fc47f3860a2d2b6105dacf5774130fd4e
Contents?: true
Size: 1 KB
Versions: 1
Compression:
Stored size: 1 KB
Contents
require "open3" module Snowball EXECUTABLE = Pathname.new(__FILE__).join("..", "roll.js").realpath class RollError < Exception; end class Roller def self.roll(entry, opts) args = [] ignores = opts[:ignores].dup ignores.unshift *%w(jsdom xmlhttprequest location navigator) ignores.uniq! args << ignores.map { |node_module| "--ignore #{node_module}" }.join(" ") args << opts[:includes].map { |node_module| "--require #{node_module}" }.join(" ") args << "--prelude #{!!opts[:prelude]}" args << "--entry #{entry}" args << "--raw" if opts[:raw] args += (opts[:env] || {}).map do |k,v| "--env #{k}=#{v}" end cmd = "node #{EXECUTABLE} #{args.join(" ")}" Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr| source = stdout.read unless wait_thr.value.success? raise RollError.new "Got error while executing \"#{cmd}\" command: #{stderr.read}" end return source end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
snowball-0.1.21 | lib/snowball/roller.rb |