Просмотр исходного кода

allow new project dir for template

pull/3/head
Tristan Sloughter 10 лет назад
Родитель
Сommit
f72b39f3c3
2 измененных файлов: 16 добавлений и 10 удалений
  1. +5
    -1
      src/rebar_prv_new.erl
  2. +11
    -9
      src/rebar_templater.erl

+ 5
- 1
src/rebar_prv_new.erl Просмотреть файл

@ -31,7 +31,11 @@ do(State) ->
case rebar_state:command_args(State) of case rebar_state:command_args(State) of
[TemplateName] -> [TemplateName] ->
Template = list_to_atom(TemplateName), Template = list_to_atom(TemplateName),
rebar_templater:new(Template, State),
rebar_templater:new(Template, "", State),
{ok, State};
[TemplateName, DirName] ->
Template = list_to_atom(TemplateName),
rebar_templater:new(Template, DirName, State),
{ok, State}; {ok, State};
[] -> [] ->
{ok, State} {ok, State}

+ 11
- 9
src/rebar_templater.erl Просмотреть файл

@ -26,7 +26,7 @@
%% ------------------------------------------------------------------- %% -------------------------------------------------------------------
-module(rebar_templater). -module(rebar_templater).
-export([new/2,
-export([new/3,
list_templates/1, list_templates/1,
create/1]). create/1]).
@ -42,13 +42,13 @@
%% Public API %% Public API
%% =================================================================== %% ===================================================================
new(app, Config) ->
create1(Config, "simpleapp");
new(lib, Config) ->
create1(Config, "simplelib");
new(node, Config) ->
new(app, DirName, Config) ->
create1(Config, DirName, "simpleapp");
new(lib, DirName, Config) ->
create1(Config, DirName, "simplelib");
new(node, DirName, Config) ->
%% Alias for create w/ template=simplenode %% Alias for create w/ template=simplenode
create1(Config, "simplenode").
create1(Config, DirName, "simplenode").
list_templates(Config) -> list_templates(Config) ->
{AvailTemplates, Files} = find_templates(Config), {AvailTemplates, Files} = find_templates(Config),
@ -69,7 +69,7 @@ list_templates(Config) ->
create(Config) -> create(Config) ->
TemplateId = template_id(Config), TemplateId = template_id(Config),
create1(Config, TemplateId).
create1(Config, "", TemplateId).
%% %%
%% Given a list of key value pairs, for each string value attempt to %% Given a list of key value pairs, for each string value attempt to
@ -100,7 +100,9 @@ render(Bin, Context) ->
%% Internal functions %% Internal functions
%% =================================================================== %% ===================================================================
create1(Config, TemplateId) ->
create1(Config, AppDir, TemplateId) ->
ec_file:mkdir_p(AppDir),
file:set_cwd(AppDir),
{AvailTemplates, Files} = find_templates(Config), {AvailTemplates, Files} = find_templates(Config),
?DEBUG("Available templates: ~p\n", [AvailTemplates]), ?DEBUG("Available templates: ~p\n", [AvailTemplates]),

Загрузка…
Отмена
Сохранить