Skip to content

Commit 6264171

Browse files
committed
Merge pull request #319 from bmjen/add-file-autorequire
adds file autorequire
2 parents e9ee044 + 78fdb4e commit 6264171

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

lib/puppet/type/concat_file.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,22 @@ def exists?
8989
end.compact
9090
end
9191

92+
# Copied from puppet's file type
93+
# Autorequire the nearest ancestor directory found in the catalog.
94+
autorequire(:file) do
95+
req = []
96+
path = Pathname.new(self[:path])
97+
if !path.root?
98+
# Start at our parent, to avoid autorequiring ourself
99+
parents = path.parent.enum_for(:ascend)
100+
if found = parents.find { |p| catalog.resource(:file, p.to_s) }
101+
req << found.to_s
102+
end
103+
end
104+
105+
req
106+
end
107+
92108
def should_content
93109
return @generated_content if @generated_content
94110
@generated_content = ""

0 commit comments

Comments
 (0)