File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -551,7 +551,9 @@ defmodule Mix.Tasks.Format do
551551 end
552552
553553 defp stdin_or_wildcard ( "-" ) , do: [ :stdin ]
554- defp stdin_or_wildcard ( path ) , do: path |> Path . expand ( ) |> Path . wildcard ( match_dot: true )
554+
555+ defp stdin_or_wildcard ( path ) ,
556+ do: path |> Path . expand ( ) |> Path . wildcard ( match_dot: true ) |> Enum . filter ( & File . regular? / 1 )
555557
556558 defp elixir_format ( content , formatter_opts ) do
557559 case Code . format_string! ( content , formatter_opts ) do
Original file line number Diff line number Diff line change @@ -81,6 +81,16 @@ defmodule Mix.Tasks.FormatTest do
8181 end )
8282 end
8383
84+ test "does not try to format a directory that matches a given pattern" , context do
85+ in_tmp ( context . test , fn ->
86+ File . mkdir_p! ( "a.ex" )
87+
88+ assert_raise Mix.Error , ~r" Could not find a file to format" , fn ->
89+ Mix.Tasks.Format . run ( [ "*.ex" ] )
90+ end
91+ end )
92+ end
93+
8494 test "reads file from stdin and prints to stdout" , context do
8595 in_tmp ( context . test , fn ->
8696 File . write! ( "a.ex" , """
You can’t perform that action at this time.
0 commit comments