summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rebar_utils.erl17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl
index 3309c24..9a0e1d9 100644
--- a/src/rebar_utils.erl
+++ b/src/rebar_utils.erl
@@ -54,7 +54,8 @@
ebin_dir/0,
processing_base_dir/1,
processing_base_dir/2,
- indent/1]).
+ indent/1,
+ cleanup_code_path/1]).
%% for internal use only
-export([otp_release/0]).
@@ -542,3 +543,17 @@ filter_defines([Opt | Rest], Acc) ->
-spec indent(non_neg_integer()) -> iolist().
indent(Amount) when erlang:is_integer(Amount) ->
[?ONE_LEVEL_INDENT || _ <- lists:seq(1, Amount)].
+
+cleanup_code_path(OrigPath) ->
+ CurrentPath = code:get_path(),
+ AddedPaths = CurrentPath -- OrigPath,
+ %% If someone has removed paths, it's hard to get them back into
+ %% the right order, but since this is currently rare, we can just
+ %% fall back to code:set_path/1.
+ case CurrentPath -- AddedPaths of
+ OrigPath ->
+ _ = [code:del_path(Path) || Path <- AddedPaths],
+ true;
+ _ ->
+ code:set_path(OrigPath)
+ end.