You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 line
1.0 KiB

  1. %% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
  2. %% ex: ts=4 sw=4 et
  3. %%
  4. %% @doc A localfs custom resource (for testing purposes only)
  5. %%
  6. %% ```
  7. %% {deps, [
  8. %% %% Application files are copied from "/path/to/app_name"
  9. %% {app_name, {localfs, "/path/to/app_name", undefined}}
  10. %% ]}.
  11. %% '''
  12. -module(rebar_localfs_resource).
  13. -behaviour(rebar_resource).
  14. -export([init/1
  15. ,lock/2
  16. ,download/3
  17. ,needs_update/2
  18. ,make_vsn/1]).
  19. -include_lib("eunit/include/eunit.hrl").
  20. -spec init(rebar_state:t()) -> {ok, term()}.
  21. init(_State) ->
  22. {ok, #{}}.
  23. lock(AppDir, {localfs, Path, _Ref}) ->
  24. lock(AppDir, {localfs, Path});
  25. lock(_AppDir, {localfs, Path}) ->
  26. {localfs, Path, undefined}.
  27. needs_update(_AppDir, _Resource) ->
  28. false.
  29. download(AppDir, {localfs, Path, _Ref}, State) ->
  30. download(AppDir, {localfs, Path}, State);
  31. download(AppDir, {localfs, Path}, _State) ->
  32. ok = rebar_file_utils:cp_r(filelib:wildcard(Path ++ "/*"), AppDir),
  33. {ok, undefined}.
  34. make_vsn(_AppDir) ->
  35. {plain, "undefined"}.