class Egads::Group

Public Class Methods

exit_on_failure?() click to toggle source

Always exit on failure

# File lib/egads/group.rb, line 8
def self.exit_on_failure?
  true
end

Protected Instance Methods

run_hooks_for(cmd, hook) click to toggle source

Run command hooks from config file E.g. run_hooks_for(:build, :after)

# File lib/egads/group.rb, line 37
def run_hooks_for(cmd, hook)
  say_status :hooks, "Running #{cmd} #{hook} hooks"
  Config.hooks_for(cmd, hook).each do |command|
    run_with_code(command, stream: true)
  end
end
run_with_code(command, options={}) click to toggle source
# File lib/egads/group.rb, line 13
def run_with_code(command, options={})

  say_status :run, "#{command}", options.fetch(:verbose, true)

  capture = []
  duration = Benchmark.realtime do
    Open3.popen2e(command) do |_, out, thread|
      out.each do |line|
        puts line if options[:stream]
        capture << line
      end

      unless thread.value == 0
        raise CommandError.new("`#{command}` failed with exit status #{thread.value.exitstatus.inspect}")
      end
    end
  end
  say_status :done, "Finished in %.1f seconds" % duration, options.fetch(:verbose, true)

  capture.join
end