Skip to content

Commit 9176804

Browse files
committed
Implement 'mix escript.uninstall' task
1 parent 90201eb commit 9176804

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

lib/mix/lib/mix/tasks/archive.uninstall.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ defmodule Mix.Tasks.Archive.Uninstall do
2323
Mix.Task.run "archive"
2424
end
2525
else
26-
Mix.raise "No archive was given to uninstall"
26+
Mix.raise "No archive was given to archive.uninstall"
2727
end
2828
end
2929
end
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
defmodule Mix.Tasks.Escript.Uninstall do
2+
use Mix.Task
3+
4+
@shortdoc "Uninstall escripts"
5+
6+
@moduledoc """
7+
Uninstall local escripts:
8+
9+
mix escript.uninstall escript_name
10+
11+
"""
12+
@spec run(OptionParser.argv) :: :ok
13+
def run(argv) do
14+
{_, argv, _} = OptionParser.parse(argv)
15+
16+
if name = List.first(argv) do
17+
path = Path.join(Mix.Local.escripts_path, name)
18+
if File.regular?(path) do
19+
File.rm!(path)
20+
else
21+
Mix.shell.error "Could not find a local escript named #{inspect name}. "<>
22+
"Existing escripts are:"
23+
Mix.Task.run "escript"
24+
end
25+
else
26+
Mix.raise "No escript was given to escript.uninstall"
27+
end
28+
end
29+
end

0 commit comments

Comments
 (0)