Sha256: 0e0d548ccc966aea7cb7572a2fbe8cf890fb365927f363d878d24ad463311d6a

Contents?: true

Size: 733 Bytes

Versions: 2

Compression:

Stored size: 733 Bytes

Contents

module Nanoc::Tidy
  module Spawn
    Error = Class.new(RuntimeError)
    def spawn(exe, argv, log:)
      Kernel.spawn(
        exe, *argv, { STDOUT => log, STDERR => log }
      )
      Process.wait
      status = $?
      ##
      # exit codes
      #  * 0: no warnings, no errors
      #  * 1: has warnings
      #  * 2: has errors
      return if [0, 1].include?(status.exitstatus)

      raise Error,
            "#{File.basename(exe)} exited unsuccessfully " \
            "(" \
            "exit code: #{status.exitstatus}, " \
            "item: #{item.identifier}" \
            ")" \
            "\n" \
            "#{log.gsub(Dir.getwd, '')[1..]}:" \
            "#{File.binread(log)}" \
            []
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nanoc-tidy.rb-0.5.5 lib/nanoc/tidy/spawn.rb
nanoc-tidy.rb-0.5.4 lib/nanoc/tidy/spawn.rb