lib/pdk/util/filesystem.rb in pdk-1.9.1 vs lib/pdk/util/filesystem.rb in pdk-1.10.0

- old
+ new

@@ -2,10 +2,16 @@ module Util module Filesystem def write_file(path, content) raise ArgumentError unless path.is_a?(String) || path.respond_to?(:to_path) - File.open(path, 'wb') { |f| f.write(content.encode(universal_newline: true)) } + # Harmonize newlines across platforms. + content = content.encode(universal_newline: true) + + # Make sure all written files have a trailing newline. + content += "\n" unless content[-1] == "\n" + + File.open(path, 'wb') { |f| f.write(content) } end module_function :write_file end end end