1
1
defmodule Mix.Tasks.Local.Rebar do
2
2
use Mix.Task
3
3
4
- @ rebar2_list_url "/installs/rebar-1.x.csv"
5
- @ rebar2_escript_url "/installs/[ELIXIR_VERSION]/rebar-[REBAR_VERSION]"
6
- @ rebar3_list_url "/installs/rebar3-1.x.csv"
7
- @ rebar3_escript_url "/installs/[ELIXIR_VERSION]/rebar3-[REBAR_VERSION]"
4
+ @ rebar2_list_url "/installs/rebar-1.x.csv"
5
+ @ rebar2_escript_url "/installs/[ELIXIR_VERSION]/rebar-[REBAR_VERSION]"
6
+ @ rebar3_list_url "/installs/rebar3-1.x.csv"
7
+ @ rebar3_escript_url "/installs/[ELIXIR_VERSION]/rebar3-[REBAR_VERSION]"
8
8
9
- @ shortdoc "Installs Rebar locally"
9
+ @ shortdoc "Installs Rebar locally"
10
10
11
11
@ moduledoc """
12
12
Fetches a copy of `rebar` or `rebar3` from the given path or URL.
@@ -47,15 +47,20 @@ defmodule Mix.Tasks.Local.Rebar do
47
47
48
48
case argv do
49
49
[ "rebar" , path | _ ] ->
50
- install_from_path ( :rebar , path , opts )
50
+ install_from_path ( :rebar , path , opts )
51
+
51
52
[ "rebar3" , path | _ ] ->
52
- install_from_path ( :rebar3 , path , opts )
53
+ install_from_path ( :rebar3 , path , opts )
54
+
53
55
[ ] ->
54
56
install_from_s3 ( :rebar , @ rebar2_list_url , @ rebar2_escript_url , opts )
55
57
install_from_s3 ( :rebar3 , @ rebar3_list_url , @ rebar3_escript_url , opts )
58
+
56
59
_ ->
57
- Mix . raise "Invalid arguments given to mix local.rebar. " <>
58
- "To find out the proper call syntax run \" mix help local.rebar\" "
60
+ Mix . raise (
61
+ "Invalid arguments given to mix local.rebar. " <>
62
+ "To find out the proper call syntax run \" mix help local.rebar\" "
63
+ )
59
64
end
60
65
end
61
66
@@ -68,13 +73,16 @@ defmodule Mix.Tasks.Local.Rebar do
68
73
File . mkdir_p! ( Path . dirname ( local ) )
69
74
File . write! ( local , binary )
70
75
File . chmod! ( local , 0o755 )
71
- Mix . shell . info [ :green , "* creating " , :reset , Path . relative_to_cwd ( local ) ]
76
+ Mix . shell ( ) . info ( [ :green , "* creating " , :reset , Path . relative_to_cwd ( local ) ] )
77
+
72
78
:badpath ->
73
- Mix . raise "Expected #{ inspect path } to be a URL or a local file path"
79
+ Mix . raise ( "Expected #{ inspect ( path ) } to be a URL or a local file path" )
80
+
74
81
{ :local , message } ->
75
- Mix . raise message
82
+ Mix . raise ( message )
83
+
76
84
{ kind , message } when kind in [ :remote , :checksum ] ->
77
- Mix . raise """
85
+ Mix . raise ( """
78
86
#{ message }
79
87
80
88
Could not fetch #{ manager } at:
@@ -84,15 +92,15 @@ defmodule Mix.Tasks.Local.Rebar do
84
92
Please download the file above manually to your current directory and run:
85
93
86
94
mix local.rebar #{ manager } ./#{ Path . basename ( local ) }
87
- """
95
+ """ )
88
96
end
89
97
end
90
98
91
99
true
92
100
end
93
101
94
102
defp install_from_s3 ( manager , list_url , escript_url , opts ) do
95
- hex_mirror = Mix.Hex . mirror
103
+ hex_mirror = Mix.Hex . mirror ( )
96
104
list_url = hex_mirror <> list_url
97
105
98
106
{ elixir_version , rebar_version , sha512 } =
0 commit comments