From b46977fc07aac028780dd05d0578dc9e3f75ede2 Mon Sep 17 00:00:00 2001 From: Christopher Bowman Date: Sun, 5 Oct 2025 18:37:10 -0400 Subject: [PATCH] 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. --- lib/puppet-lint/checks.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/puppet-lint/checks.rb b/lib/puppet-lint/checks.rb index 1908432a..7008d7e7 100644 --- a/lib/puppet-lint/checks.rb +++ b/lib/puppet-lint/checks.rb @@ -56,6 +56,7 @@ def load_data(path, content) def run(fileinfo, data) checks_run = [] if File.extname(fileinfo).downcase.match?(%r{\.ya?ml$}) + PuppetLint::Data.tokens = [] PuppetLint::Data.path = fileinfo PuppetLint::Data.manifest_lines = data.split("\n", -1) @@ -142,6 +143,10 @@ def enabled_checks # # Returns the manifest as a String. def manifest - PuppetLint::Data.tokens.map(&:to_manifest).join + if File.extname(PuppetLint::Data.path).downcase.match?(%r{\.ya?ml$}) + PuppetLint::Data.manifest_lines.join("\n") + else + PuppetLint::Data.tokens.map(&:to_manifest).join + end end end