check_edown.script 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. %% -*- erlang -*-
  2. %%
  3. %% This helper script checks if doc is being built, otherwise removes edoc dep.
  4. %% To build docs, call `rebar get-deps doc`
  5. %% Assumes that the rebar config is bound to CONFIG
  6. [_|Args] = init:get_plain_arguments(). % rebar 'commands' and options
  7. case lists:member("doc", Args) of
  8. false ->
  9. {ok,C1} = file:script(filename:join(filename:dirname(SCRIPT),
  10. "remove_deps.script"),
  11. [{'CONFIG', CONFIG}, {'DEPS', [edown]}]),
  12. C1;
  13. true ->
  14. case code:lib_dir(edown) of
  15. {error, bad_name} ->
  16. io:fwrite("cannot find edown~n", []),
  17. D = {edown, ".*",
  18. {git, "git://github.com/esl/edown.git", "HEAD"}},
  19. Deps = case lists:keyfind(deps, 1, CONFIG) of
  20. false -> [D];
  21. {_, Ds} ->
  22. case lists:keymember(edown, 1, Ds) of
  23. true -> Ds;
  24. false -> [D|Ds]
  25. end
  26. end,
  27. lists:keystore(deps, 1, CONFIG, {deps, Deps});
  28. _ ->
  29. io:fwrite("edown in path~n", []),
  30. CONFIG
  31. end
  32. end.