Module: Overcommit::Hook::Shared::RakeTarget

Included in:
PreCommit::RakeTarget, PrePush::RakeTarget
Defined in:
lib/overcommit/hook/shared/rake_target.rb

Overview

runs specified rake targets. It fails on the first non- successful exit.

Instance Method Summary collapse

Instance Method Details

#runObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/overcommit/hook/shared/rake_target.rb', line 8

def run
  targets = config['targets']

  if Array(targets).empty?
    raise 'RakeTarget: targets parameter is empty. Add at least one task to ' \
      'the targets parameter. Valid: Array of target names or String of ' \
      'target names'
  end

  targets.each do |task|
    result = execute(command + [task])
    unless result.success?
      return :fail, "Rake target #{task}:\n#{result.stdout}"
    end
  end
  :pass
end