Module: Bake::Blocks::HasExecuteCommand

Included in:
CommandLine, Docu, Makefile
Defined in:
lib/blocks/has_execute_command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



6
7
8
# File 'lib/blocks/has_execute_command.rb', line 6

def config
  @config
end

Instance Method Details

#executeCommand(commandLine, ignoreStr = nil, exitCodeArray = [0], echo = "on") ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/blocks/has_execute_command.rb', line 8

def executeCommand(commandLine, ignoreStr=nil, exitCodeArray = [0], echo = "on")
  if Bake.options.dry
    puts commandLine
    return true
  end

  puts commandLine if (Bake.options.verbose >= 1 && echo != "off") || Bake.options.verbose >= 3
  puts "(executed in '#{@projectDir}')" if Bake.options.verbose >= 3
  cmd_result = false
  output = ""
  begin
    cmd_result, output = ProcessHelper.run([commandLine], true, true, nil, exitCodeArray, @projectDir)
  rescue Exception=>e
    puts e.message
    puts e.backtrace if Bake.options.debug
  end

  if (cmd_result == false and (not ignoreStr or not output.include?ignoreStr))
    Bake.formatter.printError("Command \"#{commandLine}\" failed", @config)
    puts "(executed in '#{@projectDir}')" if Bake.options.verbose >= 3
    raise SystemCommandFailed.new
  end
  return cmd_result
end