Skip to content

Commit

Permalink
Fix save_to_file to be indentation independent
Browse files Browse the repository at this point in the history
  • Loading branch information
ShimShtein committed Aug 20, 2024
1 parent 44160c0 commit 01a722f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/services/foreman/renderer/scope/macros/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,12 @@ def save_to_file(filename, content, verbatim: false)
content = Base64.encode64(content)
"cat << #{delimiter} | base64 -d > #{filename}\n#{content}#{delimiter}"
else
content += "\n" unless content.end_with?("\n")
"cat << #{delimiter} > #{filename}\n#{content}#{delimiter}"
content_echos = content.split("\n").map do |content_line|
"echo #{Shellwords.shellescape(content_line)} >> #{filename}"
end.join('\n')

# prefix the append commands with a cleanup command
"echo '' > #{filename}\n#{content_echos}"
end
end

Expand Down

0 comments on commit 01a722f

Please sign in to comment.