lib/cc/workspace/path_tree/dir_node.rb in codeclimate-0.24.2 vs lib/cc/workspace/path_tree/dir_node.rb in codeclimate-0.24.3
- old
+ new
@@ -37,10 +37,10 @@
def add(head = nil, *tail)
return if head.nil? && tail.empty?
if (entry = find_direct_child(head))
- children[entry.basename.to_s.dup.freeze] = PathTree.node_for_pathname(entry)
+ children[entry.basename.to_s.dup.freeze] ||= PathTree.node_for_pathname(entry)
children[entry.basename.to_s.dup.freeze].add(*tail)
else
CLI.debug("Couldn't include because part of path doesn't exist.", path: File.join(root_path, head))
end
end