Skip to content

Commit 9a5a833

Browse files
committed
Clean up failed deletion warning
1 parent 4a7585f commit 9a5a833

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

lib/mix/lib/mix/tasks/deps.clean.ex

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -99,27 +99,15 @@ defmodule Mix.Tasks.Deps.Clean do
9999
paths
100100
end
101101

102-
defp maybe_warn_failed_file_deletion(results, dependency) when is_list(results) do
103-
messages =
104-
Enum.flat_map(results, fn
105-
{:error, reason, file} ->
106-
["\tfile: #{file}, reason: #{:file.format_error(reason)}"]
107-
108-
_ ->
109-
[]
110-
end)
111-
112-
with [_ | _] <- messages do
102+
defp maybe_warn_failed_file_deletion(result) do
103+
with {:error, reason, file} <- result do
113104
Mix.shell().error(
114-
"warning: errors occurred while deleting files for dependency: #{dependency} \n" <>
115-
Enum.join(messages, "\n")
105+
"warning: could not delete file #{Path.relative_to_cwd(file)}, " <>
106+
"reason: #{:file.format_error(reason)}"
116107
)
117108
end
118109
end
119110

120-
defp maybe_warn_failed_file_deletion(result, dependency),
121-
do: maybe_warn_failed_file_deletion([result], dependency)
122-
123111
defp do_clean(apps, deps, build_path, deps_path, build_only?) do
124112
shell = Mix.shell()
125113

@@ -133,8 +121,7 @@ defmodule Mix.Tasks.Deps.Clean do
133121
|> Path.join(to_string(app))
134122
|> Path.wildcard()
135123
|> maybe_warn_for_invalid_path(app)
136-
|> Enum.map(&File.rm_rf/1)
137-
|> maybe_warn_failed_file_deletion(app)
124+
|> Enum.map(&(&1 |> File.rm_rf() |> maybe_warn_failed_file_deletion()))
138125

139126
# Remove everything from the source directory of dependencies.
140127
# Skip this step if --build option is specified or if
@@ -145,7 +132,7 @@ defmodule Mix.Tasks.Deps.Clean do
145132
deps_path
146133
|> Path.join(to_string(app))
147134
|> File.rm_rf()
148-
|> maybe_warn_failed_file_deletion(app)
135+
|> maybe_warn_failed_file_deletion()
149136
end
150137
end)
151138
end

0 commit comments

Comments
 (0)