Skip to content

Commit

Permalink
add cleanup_code_path back to rebar_utils for eunit provider
Browse files Browse the repository at this point in the history
  • Loading branch information
tsloughter committed Nov 14, 2014
1 parent 039bf01 commit 33e4b7e
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/rebar_utils.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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]).
Expand Down Expand Up @@ -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.

0 comments on commit 33e4b7e

Please sign in to comment.