diff options
author | Tristan Sloughter <t@crashfast.com> | 2014-11-14 09:29:55 -0600 |
---|---|---|
committer | Tristan Sloughter <t@crashfast.com> | 2014-11-14 09:29:55 -0600 |
commit | 33e4b7e0173556bf97bfe1bbeb9d2a27bb5573fb (patch) | |
tree | 87e54f167eb60a2b890e59ebc8f2d2ebd5b866f2 /src | |
parent | 039bf01ab8f13fba384d8501cdac1146248f9206 (diff) |
add cleanup_code_path back to rebar_utils for eunit provider
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_utils.erl | 17 |
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. |