Add list-deps command

This commit is contained in:
Dave Smith 2011-04-21 06:08:40 -06:00
parent bd1475d8e3
commit 85eb2957c3

View file

@ -34,7 +34,8 @@
'check-deps'/2, 'check-deps'/2,
'get-deps'/2, 'get-deps'/2,
'update-deps'/2, 'update-deps'/2,
'delete-deps'/2]). 'delete-deps'/2,
'list-deps'/2]).
-record(dep, { dir, -record(dep, { dir,
@ -139,6 +140,18 @@ compile(Config, AppFile) ->
lists:prefix(DepsDir, D#dep.dir)], lists:prefix(DepsDir, D#dep.dir)],
ok. 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 %% Internal functions
@ -449,3 +462,10 @@ has_vcs_dir(svn, Dir) ->
orelse filelib:is_dir(filename:join(Dir, "_svn")); orelse filelib:is_dir(filename:join(Dir, "_svn"));
has_vcs_dir(_, _) -> has_vcs_dir(_, _) ->
true. 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]).