summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDave Smith <dizzyd@dizzyd.com>2011-03-29 16:42:53 -0600
committerDave Smith <dizzyd@dizzyd.com>2011-04-10 16:12:50 -0600
commit3e2baf1a07ba2512b4efc325ba2b107f69c05434 (patch)
tree61d55b0245dbe974330b09dced216883e32bb10a /src
parentb7111dce85397d9a612a60ef14830e88a0802204 (diff)
Add support for template_wildcarding; allows files from many directories to be templated.
Diffstat (limited to 'src')
-rw-r--r--src/rebar_reltool.erl15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/rebar_reltool.erl b/src/rebar_reltool.erl
index f6fd066..93a449d 100644
--- a/src/rebar_reltool.erl
+++ b/src/rebar_reltool.erl
@@ -290,6 +290,21 @@ execute_overlay([{copy, In, Out} | Rest], Vars, BaseDir, TargetDir) ->
end,
rebar_file_utils:cp_r([InFile], OutFile),
execute_overlay(Rest, Vars, BaseDir, TargetDir);
+execute_overlay([{template_wildcard, Wildcard, OutDir} | Rest], Vars, BaseDir, TargetDir) ->
+ %% Generate a series of {template, In, Out} instructions from the wildcard
+ %% that will get processed per normal
+ Ifun = fun(F, Acc0) ->
+ [{template, F, filename:join(OutDir, filename:basename(F))} | Acc0]
+ end,
+ NewInstrs = lists:foldl(Ifun, Rest, filelib:wildcard(Wildcard, BaseDir)),
+ case length(NewInstrs) == length(Rest) of
+ true ->
+ ?WARN("template_wildcard: ~s did not match any files!\n", [Wildcard]);
+ false ->
+ ok
+ end,
+ ?DEBUG("template_wildcard: ~s expanded to ~p\n", [Wildcard, NewInstrs]),
+ execute_overlay(NewInstrs, Vars, BaseDir, TargetDir);
execute_overlay([{template, In, Out} | Rest], Vars, BaseDir, TargetDir) ->
InFile = render(filename:join(BaseDir, In), Vars),
{ok, InFileData} = file:read_file(InFile),