@@ -17,26 +17,31 @@ defmodule Mix.Tasks.Local.Install do
17
17
18
18
mix some_task
19
19
20
+ ## Command line options
21
+
22
+ * `--force` forces installation without a shell prompt. Primarily
23
+ intended for automation in build systems like Make.
24
+
20
25
"""
21
26
22
27
def run ( argv ) do
23
- { _ , argv } = OptionParser . parse ( argv )
28
+ { opts , argv } = OptionParser . parse ( argv , switches: [ force: :boolean ] )
24
29
case argv do
25
30
[ ] ->
26
31
raise Mix.Error , message: "expected PATH to be given, please use `mix local.install PATH`"
27
32
[ path | _ ] ->
28
- do_install path
33
+ do_install path , opts
29
34
end
30
35
end
31
36
32
- defp do_install ( path ) do
37
+ defp do_install ( path , opts ) do
33
38
beam = Mix.Utils . read_path ( path )
34
39
{ :module , module } = get_module ( path , beam )
35
40
36
41
validate_module_name! ( path , module )
37
42
task_name = Mix.Task . task_name ( module )
38
43
39
- if Mix . shell . yes? ( "Are you sure you want to install task #{ inspect task_name } ?" ) do
44
+ if opts [ :force ] || Mix . shell . yes? ( "Are you sure you want to install task #{ inspect task_name } ?" ) do
40
45
tasks = Mix.Local . tasks_path
41
46
File . mkdir_p! tasks
42
47
create_file Path . join ( tasks , "#{ module } .beam" ) , beam
@@ -60,4 +65,4 @@ defmodule Mix.Tasks.Local.Install do
60
65
raise Mix.Error , message: "expected a Mix.Tasks module at #{ path } , got #{ other } "
61
66
end
62
67
end
63
- end
68
+ end
0 commit comments