Fix bug in templater where escript was not found in subdirs were specified in rebar.config; minor formatting cleanups

This commit is contained in:
Dave Smith 2010-02-20 20:15:07 -07:00
parent 496851cefd
commit 28d3b75641
2 changed files with 11 additions and 4 deletions

View file

@ -64,6 +64,11 @@ run(RawArgs) ->
%% Convert command strings to atoms
CommandAtoms = [list_to_atom(C) || C <- Commands],
%% Determine the location of the rebar executable; important for pulling
%% resources out of the escript
rebar_config:set_global(escript, filename:absname(escript:script_name())),
?DEBUG("Rebar location: ~p\n", [rebar_config:get_global(escript, undefined)]),
%% Load rebar.config, if it exists
process_dir(rebar_utils:get_cwd(), rebar_config:new(), CommandAtoms).

View file

@ -72,8 +72,9 @@ create(_Config, _) ->
case parse_vars(Vars, dict:new()) of
{error, Entry} ->
Context0 = undefined,
?ABORT("Failed while processing variables from template ~p. Variable definitions "
"must follow form of [{atom(), term()}]. Failed at: ~p\n",
?ABORT("Failed while processing variables from template ~p."
"Variable definitions must follow form of "
"[{atom(), term()}]. Failed at: ~p\n",
[template_id(), Entry]);
Context0 ->
ok
@ -110,7 +111,7 @@ create(_Config, _) ->
%%
cache_escript_files() ->
{ok, Files} = escript:foldl(fun(Name, _, GetBin, Acc) -> [{Name, GetBin()} | Acc] end,
[], escript:script_name()),
[], rebar_config:get_global(escript, undefined)),
erlang:put(escript_files, Files).
@ -127,7 +128,8 @@ find_escript_templates() ->
re:run(Name, ?TEMPLATE_RE, [{capture, none}]) == match].
find_disk_templates() ->
HomeFiles = rebar_utils:find_files(filename:join(os:getenv("HOME"), ".rebar/templates"), ?TEMPLATE_RE),
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].