File tree 2 files changed +9
-6
lines changed 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -544,10 +544,11 @@ defmodule Mix.Tasks.Format do
544
544
defp stdin_or_wildcard ( "-" ) , do: [ :stdin ]
545
545
defp stdin_or_wildcard ( path ) , do: path |> Path . expand ( ) |> Path . wildcard ( match_dot: true )
546
546
547
- defp elixir_format ( "" , _formatter_opts ) , do: ""
548
-
549
547
defp elixir_format ( content , formatter_opts ) do
550
- IO . iodata_to_binary ( [ Code . format_string! ( content , formatter_opts ) , ?\n ] )
548
+ case Code . format_string! ( content , formatter_opts ) do
549
+ [ ] -> ""
550
+ _ -> IO . iodata_to_binary ( [ Code . format_string! ( content , formatter_opts ) , ?\n ] )
551
+ end
551
552
end
552
553
553
554
defp find_sigils_from_plugins ( plugin , formatter_opts ) do
Original file line number Diff line number Diff line change @@ -15,13 +15,15 @@ defmodule Mix.Tasks.FormatTest do
15
15
end
16
16
end
17
17
18
- test "doesn't format empty lines into line breaks" , context do
18
+ test "doesn't format empty files into line breaks" , context do
19
19
in_tmp ( context . test , fn ->
20
20
File . write! ( "a.exs" , "" )
21
-
22
21
Mix.Tasks.Format . run ( [ "a.exs" ] )
23
-
24
22
assert File . read! ( "a.exs" ) == ""
23
+
24
+ File . write! ( "b.exs" , " \n \n " )
25
+ Mix.Tasks.Format . run ( [ "b.exs" ] )
26
+ assert File . read! ( "b.exs" ) == ""
25
27
end )
26
28
end
27
29
You can’t perform that action at this time.
0 commit comments