summaryrefslogtreecommitdiff
path: root/test/rebar_localfs_resource.erl
blob: 3d1296a9781dd88507376aaf0c8951397ae920e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ts=4 sw=4 et
%%
%% @doc A localfs custom resource (for testing purposes only)
%% implementing the deprecated rebar_resource instead of v2
%%
%% ```
%% {deps, [
%%     %% Application files are copied from "/path/to/app_name"
%%     {app_name, {localfs, "/path/to/app_name", undefined}}
%% ]}.
%% '''
-module(rebar_localfs_resource).

-behaviour(rebar_resource).

-export([init/1
        ,lock/2
        ,download/3
        ,needs_update/2
        ,make_vsn/1]).

-include_lib("eunit/include/eunit.hrl").

-spec init(rebar_state:t()) -> {ok, term()}.
init(_State) ->
    {ok, #{}}.

lock(AppDir, {localfs, Path, _Ref}) ->
    lock(AppDir, {localfs, Path});
lock(_AppDir, {localfs, Path}) ->
    {localfs, Path, undefined}.

needs_update(_AppDir, _Resource) ->
    false.

download(AppDir, {localfs, Path, _Ref}, State) ->
    download(AppDir, {localfs, Path}, State);
download(AppDir, {localfs, Path}, _State) ->
    ok = rebar_file_utils:cp_r(filelib:wildcard(Path ++ "/*"), AppDir),
    {ok, undefined}.

make_vsn(_AppDir) ->
    {plain, "undefined"}.