Module: Kernel

Defined in:
lib/rake_ci_tools/runners/sh.rb

Instance Method Summary collapse

Instance Method Details

#sh(*cmd, &block) ⇒ Object

Define sh runner



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/rake_ci_tools/runners/sh.rb', line 3

def sh(*cmd, &block)
    if Hash === cmd.last then
      options = cmd.pop
    else
      options = {}
    end
    unless block_given?
      block = lambda { |ok, status|
        ok or fail "Command failed with status (#{status.exitstatus}): [#{cmd.join(" ")}]"
      }
    end
    res = system(*cmd)      
    block.call(res, $?)
end