@@ -17,26 +17,31 @@ defmodule Mix.Tasks.Local.Install do
1717
1818 mix some_task
1919
20+ ## Command line options
21+
22+ * `--force` forces installation without a shell prompt. Primarily
23+ intended for automation in build systems like Make.
24+
2025 """
2126
2227 def run ( argv ) do
23- { _ , argv } = OptionParser . parse ( argv )
28+ { opts , argv } = OptionParser . parse ( argv , switches: [ force: :boolean ] )
2429 case argv do
2530 [ ] ->
2631 raise Mix.Error , message: "expected PATH to be given, please use `mix local.install PATH`"
2732 [ path | _ ] ->
28- do_install path
33+ do_install path , opts
2934 end
3035 end
3136
32- defp do_install ( path ) do
37+ defp do_install ( path , opts ) do
3338 beam = Mix.Utils . read_path ( path )
3439 { :module , module } = get_module ( path , beam )
3540
3641 validate_module_name! ( path , module )
3742 task_name = Mix.Task . task_name ( module )
3843
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
4045 tasks = Mix.Local . tasks_path
4146 File . mkdir_p! tasks
4247 create_file Path . join ( tasks , "#{ module } .beam" ) , beam
@@ -60,4 +65,4 @@ defmodule Mix.Tasks.Local.Install do
6065 raise Mix.Error , message: "expected a Mix.Tasks module at #{ path } , got #{ other } "
6166 end
6267 end
63- end
68+ end
0 commit comments