/
archive.ex
36 lines (29 loc) · 913 Bytes
/
archive.ex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
defmodule Mix.Tasks.Archive do
use Mix.Task
@shortdoc "Lists installed archives"
@moduledoc """
Lists all installed archives.
Archives are typically installed at `~/.mix/archives`
although the installation path can be customized by
setting the `MIX_ARCHIVES` environment variable.
Since archives are specific to Elixir versions, it is
expected from build tools to swap the `MIX_ARCHIVES`
variable to different locations based on a particular
Elixir installation.
"""
@impl true
def run(_) do
Mix.path_for(:archives)
|> Path.join("*")
|> Path.wildcard()
|> Enum.map(&Path.basename/1)
|> print()
end
defp print([]) do
Mix.shell().info("No archives currently installed.")
end
defp print(items) do
Enum.each(items, fn item -> Mix.shell().info(["* ", item]) end)
Mix.shell().info("Archives installed at: #{Mix.path_for(:archives)}")
end
end