Module: Nanoc::WeasyPrint::Spawn

Included in:
Filter
Defined in:
lib/nanoc/weasyprint/spawn.rb

Constant Summary collapse

Error =
Class.new(RuntimeError)

Instance Method Summary collapse

Instance Method Details

#spawn(exe, argv, log:) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/nanoc/weasyprint/spawn.rb', line 4

def spawn(exe, argv, log:)
  Kernel.spawn(
    exe, *argv, { STDOUT => log, STDERR => log }
  )
  Process.wait
  unless $?.success?
    raise Error,
          "#{File.basename(exe)} exited unsuccessfully " \
          "(exit code: #{$?.exitstatus}, " \
          "item: #{item.identifier}, " \
          "log: #{log.gsub(Dir.getwd, '')[1..]})",
          []
  end
end