Skip to content

Commit 5009b4a

Browse files
committed
Intercept download and needs_update in rebar_fetch
1 parent 3f249fd commit 5009b4a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/rebar_fetch.erl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ download_source(AppInfo, State) ->
5050
end.
5151

5252
download_source_(AppInfo, State) ->
53+
case os:getenv("REBAR_OFFLINE") of
54+
"1" ->
55+
{error, {?MODULE, offline}};
56+
_ ->
57+
download_source_online(AppInfo, State)
58+
end.
59+
60+
download_source_online(AppInfo, State) ->
5361
AppDir = rebar_app_info:dir(AppInfo),
5462
TmpDir = ec_file:insecure_mkdtemp(),
5563
AppDir1 = rebar_utils:to_list(AppDir),
@@ -68,6 +76,17 @@ download_source_(AppInfo, State) ->
6876
-spec needs_update(rebar_app_info:t(), rebar_state:t())
6977
-> boolean() | {error, string()}.
7078
needs_update(AppInfo, State) ->
79+
case os:getenv("REBAR_OFFLINE") of
80+
"1" ->
81+
?DEBUG("Can't check if dependency needs updates in offline mode", []),
82+
true;
83+
_ ->
84+
needs_update_online(AppInfo, State)
85+
end.
86+
87+
-spec needs_update_online(rebar_app_info:t(), rebar_state:t())
88+
-> boolean() | {error, string()}.
89+
needs_update_online(AppInfo, State) ->
7190
try
7291
rebar_resource_v2:needs_update(AppInfo, State)
7392
catch

0 commit comments

Comments
 (0)