Skip to content

Commit b46977f

Browse files
committed
Do not overwrite yaml files with previously read in data
Fixes issue #254. Re-initialize the PuppetLine::Data structure when reading in yaml files. Also, when obtaining the "manifest", return the stored manifest_lines values if the read-in contents are from a yaml file.
1 parent 6b988a2 commit b46977f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/puppet-lint/checks.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def load_data(path, content)
5656
def run(fileinfo, data)
5757
checks_run = []
5858
if File.extname(fileinfo).downcase.match?(%r{\.ya?ml$})
59+
PuppetLint::Data.tokens = []
5960
PuppetLint::Data.path = fileinfo
6061
PuppetLint::Data.manifest_lines = data.split("\n", -1)
6162

@@ -142,6 +143,10 @@ def enabled_checks
142143
#
143144
# Returns the manifest as a String.
144145
def manifest
145-
PuppetLint::Data.tokens.map(&:to_manifest).join
146+
if File.extname(PuppetLint::Data.path).downcase.match?(%r{\.ya?ml$})
147+
PuppetLint::Data.manifest_lines.join("\n")
148+
else
149+
PuppetLint::Data.tokens.map(&:to_manifest).join
150+
end
146151
end
147152
end

0 commit comments

Comments
 (0)