Skip to content

Commit

Permalink
Add list-deps command
Browse files Browse the repository at this point in the history
  • Loading branch information
dizzyd committed Apr 21, 2011
1 parent bd1475d commit 85eb295
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/rebar_deps.erl
Expand Up @@ -34,7 +34,8 @@
'check-deps'/2,
'get-deps'/2,
'update-deps'/2,
'delete-deps'/2]).
'delete-deps'/2,
'list-deps'/2]).


-record(dep, { dir,
Expand Down Expand Up @@ -139,6 +140,18 @@ compile(Config, AppFile) ->
lists:prefix(DepsDir, D#dep.dir)],
ok.

'list-deps'(Config, _) ->
Deps = rebar_config:get_local(Config, deps, []),
case find_deps(find, Deps) of
{AvailDeps, []} ->
lists:foreach(fun(Dep) ->
?CONSOLE("~s\n", [print_source(Dep#dep.source)])
end, AvailDeps),
ok;
{_, MissingDeps} ->
?ABORT("Missing dependencies: ~p\n", [MissingDeps])
end.


%% ===================================================================
%% Internal functions
Expand Down Expand Up @@ -449,3 +462,10 @@ has_vcs_dir(svn, Dir) ->
orelse filelib:is_dir(filename:join(Dir, "_svn"));
has_vcs_dir(_, _) ->
true.

print_source({git, Url}) -> ?FMT("BRANCH ~s ~s", ["HEAD", Url]);
print_source({git, Url, ""}) -> ?FMT("BRANCH ~s ~s", ["HEAD", Url]);
print_source({git, Url, {branch, Branch}}) -> ?FMT("BRANCH ~s ~s", [Branch, Url]);
print_source({git, Url, {tag, Tag}}) -> ?FMT("TAG ~s ~s", [Tag, Url]);
print_source({_, Url, Rev}) -> ?FMT("REV ~s ~s", [Rev, Url]).

0 comments on commit 85eb295

Please sign in to comment.