Class: Textus::Doctor::Check::PublishTreeIndexOverlap
- Inherits:
-
Check
- Object
- Check
- Textus::Doctor::Check::PublishTreeIndexOverlap
- Defined in:
- lib/textus/doctor/check/publish_tree_index_overlap.rb
Overview
ADR 0047 Decision 4. A publish_tree entry prunes its WHOLE target dir on
every build. If a derived entry's publish_to writes a file into that same
dir, the tree's prune will delete it unless the tree ignores that
filename. Warn so the author adds the ignore before prune eats the index.
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/textus/doctor/check/publish_tree_index_overlap.rb', line 9 def call entries = manifest.data.entries trees = entries.select { |e| e.nested? && e.publish_tree } return [] if trees.empty? derived_targets = entries.flat_map do |e| Array(e.publish_to).map { |rel| [e, rel] } end trees.flat_map do |tree| target_prefix = "#{tree.publish_tree.chomp("/")}/" derived_targets.filter_map do |(derived, rel)| next nil unless rel.start_with?(target_prefix) rel_to_target = rel.delete_prefix(target_prefix) next nil if tree.ignored?(rel_to_target) issue(tree, derived, rel, rel_to_target) end end end |