Skip to content

Commit 70b4c06

Browse files
committed
Allow queries in mix local.install URL
1 parent 620e452 commit 70b4c06

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

lib/mix/lib/mix/tasks/local.install.ex

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,22 @@ defmodule Mix.Tasks.Local.Install do
3232
def run(argv) do
3333
{ opts, argv, _ } = OptionParser.parse(argv, switches: [force: :boolean])
3434

35-
unless path = List.first(argv) do
35+
if url = List.first(argv) do
36+
URI.Info[path: path] = URI.parse(url)
37+
38+
case Path.extname(path) do
39+
".ez" -> install_archive(url, opts)
40+
_ -> raise Mix.Error, message: "mix local.install doesn't know how to install #{path}"
41+
end
42+
else
3643
path = Mix.Archive.name(Mix.project[:app], Mix.project[:version])
3744

38-
unless File.exists?(path) do
45+
if File.exists?(path) do
46+
install_archive(path, opts)
47+
else
3948
raise Mix.Error, message: "Expected PATH to be given, please use `mix local.install PATH`"
4049
end
4150
end
42-
43-
case Path.extname(path) do
44-
".ez" -> install_archive(path, opts)
45-
_ -> raise Mix.Error, message: "mix local.install doesn't know how to install #{path}"
46-
end
4751
end
4852

4953
defp install_archive(src, opts) do
@@ -52,10 +56,15 @@ defmodule Mix.Tasks.Local.Install do
5256
remove_previous_versions(previous)
5357
dest = Mix.Local.archives_path
5458
File.mkdir_p! dest
55-
create_file Path.join(dest, Path.basename(src)), Mix.Utils.read_path!(src)
59+
create_file Path.join(dest, basename(src)), Mix.Utils.read_path!(src)
5660
end
5761
end
5862

63+
defp basename(path) do
64+
URI.Info[path: path] = URI.parse(path)
65+
Path.basename(path)
66+
end
67+
5968
defp should_install?(src, []) do
6069
Mix.shell.yes?("Are you sure you want to install archive #{src}?")
6170
end

0 commit comments

Comments
 (0)