Method: Terraspace::Dependency::Graph#check_cycle

Defined in:
lib/terraspace/dependency/graph.rb

#check_cycle(node, depth = 0, list = []) ⇒ Object



37
38
39
40
41
42
43
44
45
# File 'lib/terraspace/dependency/graph.rb', line 37

def check_cycle(node, depth=0, list=[])
  if depth > MAX_CYCLE_DEPTH
    logger.error "ERROR: It seems like there is a circular dependency! Stacks involved: #{list.uniq}".color(:red)
    exit 1
  end
  node.parents.each do |parent|
    check_cycle(parent, depth+1, list += [parent])
  end
end