Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(PDK-1308) Ensure PDK-written non-templated files have trailing newline #640

Merged
merged 1 commit into from
Mar 21, 2019

Conversation

scotje
Copy link
Contributor

@scotje scotje commented Mar 19, 2019

There are some files that PDK writes that are not derived from templates
in the pdk-templates repo. The most notable example of this is the
metadata.json file which is constructed as a Ruby hash and then
serialized to JSON and written to a file. When PDK writes these files it
was not including a trailing newline and files having trailing newlines
is a best practice.

This change updates the PDK::Util::Filesystem.write_file method to
ensure that it always writes files with a trailing newline.

Some of the unit tests around writing templated files also needed to be
updated because of the way the tests were implemented did not simulate
template files that already contained trailing newlines.

@scotje
Copy link
Contributor Author

scotje commented Mar 19, 2019

Will resolve #636

@coveralls
Copy link

coveralls commented Mar 19, 2019

Coverage Status

Coverage increased (+0.005%) to 92.931% when pulling b514ae9 on scotje:1308_trailing_newlines into 16722fb on puppetlabs:master.

lib/pdk/util/filesystem.rb Show resolved Hide resolved
There are some files that PDK writes that are not derived from templates
in the pdk-templates repo. The most notable example of this is the
metadata.json file which is constructed as a Ruby hash and then
serialized to JSON and written to a file. When PDK writes these files it
was not including a trailing newline and files having trailing newlines
is a best practice.

This change updates the PDK::Util::Filesystem.write_file method to
ensure that it always writes files with a trailing newline.

Some of the unit tests around writing templated files also needed to be
updated because of the way the tests were implemented did not simulate
template files that already contained trailing newlines.
@scotje
Copy link
Contributor Author

scotje commented Mar 20, 2019

@rodjek updated

@scotje scotje requested a review from rodjek March 20, 2019 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants