From 59a7bb51652598c456bf72409083261b988b84aa Mon Sep 17 00:00:00 2001 From: Fred Hebert Date: Mon, 6 Feb 2017 00:39:10 -0500 Subject: Add support for global plugin-defined templates Did not really know how to automate the testing for this, did it by hand. --- src/rebar_templater.erl | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') diff --git a/src/rebar_templater.erl b/src/rebar_templater.erl index 9b33ec5..1c28788 100644 --- a/src/rebar_templater.erl +++ b/src/rebar_templater.erl @@ -334,8 +334,19 @@ find_plugin_templates(State) -> || App <- rebar_state:all_plugin_deps(State), Priv <- [rebar_app_info:priv_dir(App)], Priv =/= undefined, + File <- rebar_utils:find_files(Priv, ?TEMPLATE_RE)] + ++ %% and add global plugins too + [{plugin, File} + || PSource <- rebar_state:get(State, {plugins, global}, []), + Plugin <- [plugin_provider(PSource)], + is_atom(Plugin), + Priv <- [code:priv_dir(Plugin)], + Priv =/= undefined, File <- rebar_utils:find_files(Priv, ?TEMPLATE_RE)]. +plugin_provider(P) when is_atom(P) -> P; +plugin_provider(T) when is_tuple(T) -> element(1, T). + %% Take an existing list of templates and tag them by name the way %% the user would enter it from the CLI tag_names(List) -> -- cgit v1.1