Skip to content

Commit f167716

Browse files
ericmjJosé Valim
authored andcommitted
Unload previous archive versions before building (#8253)
Signed-off-by: José Valim <[email protected]>
1 parent 0cdf6d2 commit f167716

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/mix/lib/mix/tasks/archive.install.ex

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,15 @@ defmodule Mix.Tasks.Archive.Install do
113113
end
114114

115115
def build(_install_spec, _opts) do
116+
src = Mix.Local.name_for(:archive, Mix.Project.config())
117+
previous = find_previous_versions(src)
118+
119+
Enum.each(previous, fn path ->
120+
Code.delete_path(Mix.Local.archive_ebin(path))
121+
end)
122+
116123
Mix.Task.run("archive.build", [])
117-
Mix.Local.name_for(:archive, Mix.Project.config())
124+
src
118125
end
119126

120127
### Private helpers

lib/mix/test/mix/tasks/archive_test.exs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ defmodule Mix.Tasks.ArchiveTest do
183183
send(self(), {:mix_shell_input, :yes?, true})
184184
Mix.Tasks.Archive.Uninstall.run(["archive-0.2.0"])
185185
refute File.dir?(tmp_path("userhome/.mix/archives/archive-0.2.0/archive-0.2.0/ebin"))
186+
187+
# Check old paths are unloaded
188+
paths = Enum.map(:code.get_path(), &List.to_string/1)
189+
refute tmp_path("userhome/.mix/archives/archive-0.1.0/archive-0.1.0/ebin") in paths
186190
end)
187191
end
188192

0 commit comments

Comments
 (0)