8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/snowball/roller.rb', line 8
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
|