diff options
author | Tristan Sloughter <t@crashfast.com> | 2015-08-17 17:39:31 -0500 |
---|---|---|
committer | Tristan Sloughter <t@crashfast.com> | 2015-08-17 17:39:31 -0500 |
commit | e941e170e4572d6f5252232b4fd75f1fa4cad2c2 (patch) | |
tree | cf44a985ac56f6f31a563e1666c284f811b8e5ce | |
parent | 1f72ddf04277322a162ff3235f029f28541a2c14 (diff) |
small refactorings per Fred comments
-rw-r--r-- | src/rebar_app_discover.erl | 22 | ||||
-rw-r--r-- | src/rebar_digraph.erl | 9 |
2 files changed, 16 insertions, 15 deletions
diff --git a/src/rebar_app_discover.erl b/src/rebar_app_discover.erl index 6eeadf0..e81a323 100644 --- a/src/rebar_app_discover.erl +++ b/src/rebar_app_discover.erl @@ -20,15 +20,7 @@ do(State, LibDirs) -> %% There may be a top level src which is an app and there may not %% Find it here if there is, otherwise define the deps parent as root - TopLevelApp = case ec_lists:find(fun(X) -> - ec_file:real_dir_path(rebar_app_info:dir(X)) =:= - ec_file:real_dir_path(rebar_dir:root_dir(State)) - end, Apps) of - {ok, App} -> - rebar_app_info:name(App); - error -> - root - end, + TopLevelApp = define_root_app(Apps, State), %% Handle top level deps State1 = lists:foldl(fun(Profile, StateAcc) -> @@ -61,6 +53,18 @@ do(State, LibDirs) -> end end, State1, SortedApps). +define_root_app(Apps, State) -> + RootDir = rebar_dir:root_dir(State), + case ec_lists:find(fun(X) -> + ec_file:real_dir_path(rebar_app_info:dir(X)) =:= + ec_file:real_dir_path(RootDir) + end, Apps) of + {ok, App} -> + rebar_app_info:name(App); + error -> + root + end. + format_error({module_list, File}) -> io_lib:format("Error reading module list from ~p~n", [File]); format_error({missing_module, Module}) -> diff --git a/src/rebar_digraph.erl b/src/rebar_digraph.erl index f2bb540..472a543 100644 --- a/src/rebar_digraph.erl +++ b/src/rebar_digraph.erl @@ -108,12 +108,9 @@ cull_deps(Graph, [{Profile, Level, Vs} | Vertices], Levels, Solution, Seen, Disc %% Combine lists of deps that have the same profile and level combine_profile_levels(Vertices, NewVertices) -> V = lists:foldl(fun({Profile, Level, Vs}, Acc) -> - case ec_lists:find(fun({P, L, _}) when P =:= Profile - , L =:= Level -> - true; - (_) -> - false - end, Acc) of + case ec_lists:find(fun({P, L, _}) -> + P =:= Profile andalso L =:= Level + end, Acc) of {ok, {_, _, OldVs}=Old} -> lists:delete(Old, Acc)++[{Profile, Level, lists:keysort(1, OldVs++Vs)}]; error -> |