check_edown.script 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  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 = case init:get_plain_arguments() of
  7. [_|A] -> A; % rebar 'commands' and options
  8. _ -> []
  9. end.
  10. case lists:member("doc", Args) of
  11. false ->
  12. {ok,C1} = file:script(filename:join(filename:dirname(SCRIPT),
  13. "remove_deps.script"),
  14. [{'CONFIG', CONFIG}, {'DEPS', [edown]}]),
  15. C1;
  16. true ->
  17. case code:lib_dir(edown) of
  18. {error, bad_name} ->
  19. io:fwrite("cannot find edown~n", []),
  20. D = {edown, ".*",
  21. {git, "git://github.com/uwiger/edown.git", "HEAD"}},
  22. Deps = case lists:keyfind(deps, 1, CONFIG) of
  23. false -> [D];
  24. {_, Ds} ->
  25. case lists:keymember(edown, 1, Ds) of
  26. true -> Ds;
  27. false -> [D|Ds]
  28. end
  29. end,
  30. lists:keystore(deps, 1, CONFIG, {deps, Deps});
  31. _ ->
  32. io:fwrite("edown in path~n", []),
  33. CONFIG
  34. end
  35. end.