Skip to content

Commit 7d3c96d

Browse files
orienviraptor
andcommitted
Improve #format_lines_for_cloudformation for readability and performance
Co-authored-by: Stanisław Pitucha <stan.pitucha@envato.com>
1 parent de715c4 commit 7d3c96d

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

lib/stack_master/cloudformation_interpolating_eruby.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@ def format_lines_for_cloudformation(source)
5050
lines = lines.to_s if lines.is_a?(Symbol)
5151
next(lines) unless lines.is_a?(String)
5252

53-
newlines = Array.new(lines.count("\n"), "\n")
54-
newlines = lines.split("\n").map { |line| "#{line}#{newlines.pop}" }
55-
newlines.insert(0, "\n") if lines.start_with?("\n")
56-
newlines
53+
lines.scan(/[^\n]*\n?/).reject { |x| x == '' }
5754
end
5855
end
5956
end

0 commit comments

Comments
 (0)