Skip to content

Commit

Permalink
Merge pull request #378 from envato/improve_format_lines_for_cloudfor…
Browse files Browse the repository at this point in the history
…mation

Improve `#format_lines_for_cloudformation` for readability and performance
  • Loading branch information
orien committed Feb 5, 2024
2 parents de715c4 + 2479523 commit 5ad2eb3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The format is based on [Keep a Changelog], and this project adheres to
- Introduce `user_data_file`, `user_data_file_as_lines`, and `include_file`
convenience methods to the YAML ERB template compiler ([#377]).

[2.13.4]: https://github.com/envato/stack_master/compare/v2.13.4...v2.14.0
[2.14.0]: https://github.com/envato/stack_master/compare/v2.13.4...v2.14.0
[#375]: https://github.com/envato/stack_master/pull/375
[#376]: https://github.com/envato/stack_master/pull/376
[#377]: https://github.com/envato/stack_master/pull/377
Expand Down
5 changes: 1 addition & 4 deletions lib/stack_master/cloudformation_interpolating_eruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@ def format_lines_for_cloudformation(source)
lines = lines.to_s if lines.is_a?(Symbol)
next(lines) unless lines.is_a?(String)

newlines = Array.new(lines.count("\n"), "\n")
newlines = lines.split("\n").map { |line| "#{line}#{newlines.pop}" }
newlines.insert(0, "\n") if lines.start_with?("\n")
newlines
lines.scan(/[^\n]*\n?/).reject { |x| x == '' }
end
end
end
Expand Down

0 comments on commit 5ad2eb3

Please sign in to comment.