Sha256: 5f8ca5d3c4f4aeabe8cefbb541ebb13bfa44f76b04c3e71c712c74320fab3cc1
Contents?: true
Size: 1.12 KB
Versions: 6
Compression:
Stored size: 1.12 KB
Contents
# frozen_string_literal: true require 'English' class ImageOptim # Helper for running commands module Cmd class << self # Run using `system` # Return success status # Will raise SignalException if process was interrupted def run(*args) success = system(*args) check_status! success end # Run using backtick # Return captured output # Will raise SignalException if process was interrupted def capture(cmd) output = `#{cmd}` check_status! output end private def check_status! status = $CHILD_STATUS return unless status.signaled? # jruby incorrectly returns true for `signaled?` if process exits with # non zero status. For following code # # `sh -c 'exit 66'` # p [$?.signaled?, $?.exitstatus, $?.termsig] # # jruby outputs `[true, 66, 66]` instead of expected `[false, 66, nil]` return if defined?(JRUBY_VERSION) && status.exitstatus == status.termsig fail SignalException, status.termsig end end end end
Version data entries
6 entries across 6 versions & 1 rubygems