Skip to content

Commit 927cab7

Browse files
committed
Support obtaining *.ex paths from given directory
1 parent c0982d4 commit 927cab7

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

lib/mix/tasks/gradient.ex

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ defmodule Mix.Tasks.Gradient do
5858

5959
@impl Mix.Task
6060
def run(args) do
61-
{options, usr_paths, _invalid} = OptionParser.parse(args, strict: @options)
61+
{options, user_paths, _invalid} = OptionParser.parse(args, strict: @options)
6262

6363
options = Enum.reduce(options, [], &prepare_option/2)
6464

@@ -67,8 +67,8 @@ defmodule Mix.Tasks.Gradient do
6767
maybe_compile_project(options)
6868
# Load dependencies
6969
maybe_load_deps(options)
70-
# Get beam files
71-
files = get_beams_paths(usr_paths)
70+
# Get paths to files
71+
files = get_paths(user_paths)
7272

7373
IO.puts("Typechecking files...")
7474

@@ -131,16 +131,27 @@ defmodule Mix.Tasks.Gradient do
131131

132132
defp prepare_option({k, v}, opts), do: [{k, v} | opts]
133133

134-
defp get_beams_paths([]) do
134+
defp get_paths([]), do: get_beam_paths()
135+
defp get_paths(paths), do: %{nil => get_paths_from_dir(paths)}
136+
137+
defp get_beam_paths() do
135138
if Mix.Project.umbrella?() do
136139
get_umbrella_app_beams_paths()
137140
else
138141
get_app_beams_paths()
139142
end
140143
end
141144

142-
defp get_beams_paths(paths) do
143-
%{nil => paths}
145+
defp get_paths_from_dir(paths) do
146+
paths
147+
|> Enum.map(fn p ->
148+
if File.dir?(p) do
149+
Path.wildcard(Path.join([p, "*.ex"]))
150+
else
151+
[p]
152+
end
153+
end)
154+
|> Enum.concat()
144155
end
145156

146157
defp get_app_beams_paths() do

0 commit comments

Comments
 (0)