From b32eeeafb7f5cb90a5c73a541e55b62556efee80 Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Sat, 28 Aug 2010 08:04:47 -0600 Subject: [PATCH] Add support for specifying template directory on the command line --- src/rebar_templater.erl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/rebar_templater.erl b/src/rebar_templater.erl index e338455..e27c203 100644 --- a/src/rebar_templater.erl +++ b/src/rebar_templater.erl @@ -146,10 +146,19 @@ find_escript_templates() -> re:run(Name, ?TEMPLATE_RE, [{capture, none}]) == match]. find_disk_templates() -> + OtherTemplates = find_other_templates(), HomeFiles = rebar_utils:find_files(filename:join(os:getenv("HOME"), ".rebar/templates"), ?TEMPLATE_RE), LocalFiles = rebar_utils:find_files(".", ?TEMPLATE_RE), - [{file, F} || F <- HomeFiles++LocalFiles]. + [{file, F} || F <- OtherTemplates ++ HomeFiles ++ LocalFiles]. + +find_other_templates() -> + case rebar_config:get_global(template_dir, undefined) of + undefined -> + []; + TemplateDir -> + rebar_utils:find_files(TemplateDir, ?TEMPLATE_RE) + end. select_template([], Template) -> ?ABORT("Template ~s not found.\n", [Template]);