Explorar el Código

small refactorings per Fred comments

pull/718/head
Tristan Sloughter hace 9 años
padre
commit
e941e170e4
Se han modificado 2 ficheros con 16 adiciones y 15 borrados
  1. +13
    -9
      src/rebar_app_discover.erl
  2. +3
    -6
      src/rebar_digraph.erl

+ 13
- 9
src/rebar_app_discover.erl Ver fichero

@ -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}) ->

+ 3
- 6
src/rebar_digraph.erl Ver fichero

@ -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 ->

Cargando…
Cancelar
Guardar