Skip to content

Commit

Permalink
Add an ending newline to generated files
Browse files Browse the repository at this point in the history
  • Loading branch information
ahamez committed Mar 2, 2022
1 parent 6121a92 commit b10318f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 2 additions & 10 deletions lib/protox/generate.ex
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,10 @@ defmodule Protox.Generate do
end

defp generate_file_content(code) do
code_str = Macro.to_string(code)

formatted_code =
try do
Code.format_string!(code_str)
rescue
_ -> code_str
end

[
"# credo:disable-for-this-file\n",
formatted_code
code |> Macro.to_string() |> Code.format_string!(),
"\n"
]
end
end
12 changes: 12 additions & 0 deletions test/code_generation_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,18 @@ defmodule Protox.CodeGenerationTest do
)

assert credo_exit_status == 0

{_, mix_format_exit_status} =
System.cmd(
"mix",
[
"format",
"--check-formatted"
],
cd: code_generation_path
)

assert mix_format_exit_status == 0
end

defp mix_exs() do
Expand Down

0 comments on commit b10318f

Please sign in to comment.