-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
clean.ex
55 lines (43 loc) · 1.44 KB
/
clean.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
defmodule Mix.Tasks.Nerves.Clean do
@shortdoc "Cleans dependencies and build artifacts"
@moduledoc deprecated: "Tasks from :nerves should be used instead"
@moduledoc """
Cleans dependencies and build artifacts
Since this is a destructive action, cleaning of dependencies
only occurs when one of the following are specified:
* `dep1 dep2` - the names of Nerves dependencies to be cleaned, separated by spaces
* `--all` - cleans all Nerves dependencies
"""
use Mix.Task
import Mix.Nerves.IO
@switches [all: :boolean]
@impl Mix.Task
def run(argv) do
debug_info("Clean Start")
{opts, packages, _} = OptionParser.parse(argv, switches: @switches)
# Start the Nerves env with the precompiler disabled
# so we can clean the package without building it.
Mix.Tasks.Nerves.Env.run(["--disable"])
packages =
case packages do
[] ->
if opts[:all] do
Nerves.Env.packages()
else
Mix.raise("""
You must specify the Nerves dependencies to clean, separated by spaces
Example:
mix nerves.clean nerves_system_rpi3
Or by passing --all
mix nerves.clean --all
""")
end
packages ->
packages
|> Enum.map(&String.to_existing_atom/1)
|> Enum.map(&Nerves.Env.package/1)
end
debug_info("Clean End")
Nerves.Env.clean(packages)
end
end