diff options
| author | Fred Hebert <mononcqc@ferd.ca> | 2015-08-04 17:28:40 -0400 |
|---|---|---|
| committer | Fred Hebert <mononcqc@ferd.ca> | 2015-08-04 17:28:40 -0400 |
| commit | 1a061b9c9a27c46b079caf2fa80aaf5d541823b8 (patch) | |
| tree | 8ea00ccea472a903445038b882e71f2ccafb46d8 /src/rebar_utils.erl | |
| parent | a705f1e4f6a93313546fd68ce857a6d69a45661a (diff) | |
| parent | 4bcab8ef9643750808f5133b1ee074fbe66bdcfe (diff) | |
Merge pull request #610 from tsloughter/deps_tree
add tree option to deps command that prints pkg deps tree
Diffstat (limited to 'src/rebar_utils.erl')
| -rw-r--r-- | src/rebar_utils.erl | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl index 30da523..c7128fc 100644 --- a/src/rebar_utils.erl +++ b/src/rebar_utils.erl @@ -54,6 +54,8 @@ expand_env_variable/3, get_arch/0, wordsize/0, + deps_to_binary/1, + tup_dedup/1, tup_umerge/2, tup_sort/1, tup_find/2, @@ -236,6 +238,30 @@ erl_opts(Config) -> %% was enclosed in quotes and might have commas but should not be split. args_to_tasks(Args) -> new_task(Args, []). +deps_to_binary([]) -> + []; +deps_to_binary([{Name, _, Source} | T]) -> + [{ec_cnv:to_binary(Name), Source} | deps_to_binary(T)]; +deps_to_binary([{Name, Source} | T]) -> + [{ec_cnv:to_binary(Name), Source} | deps_to_binary(T)]; +deps_to_binary([Name | T]) -> + [ec_cnv:to_binary(Name) | deps_to_binary(T)]. + +tup_dedup([]) -> + []; +tup_dedup([A]) -> + [A]; +tup_dedup([A,B|T]) when element(1, A) =:= element(1, B) -> + tup_dedup([A | T]); +tup_dedup([A,B|T]) when element(1, A) =:= B -> + tup_dedup([A | T]); +tup_dedup([A,B|T]) when A =:= element(1, B) -> + tup_dedup([A | T]); +tup_dedup([A,A|T]) -> + [A|tup_dedup(T)]; +tup_dedup([A|T]) -> + [A|tup_dedup(T)]. + %% Sort the list in proplist-order, meaning that `{a,b}' and `{a,c}' %% both compare as usual, and `a' and `b' do the same, but `a' and `{a,b}' will %% compare based on the first element of the key, and in order. So the following |
