mirror of
https://github.com/correl/rebar.git
synced 2024-12-18 03:00:17 +00:00
Tidier improvements
This commit is contained in:
parent
1a577fcd43
commit
7dc76d578e
16 changed files with 78 additions and 99 deletions
|
@ -171,13 +171,13 @@ get(Key, Ctx, Mod) ->
|
||||||
error ->
|
error ->
|
||||||
case erlang:function_exported(Mod, Key, 1) of
|
case erlang:function_exported(Mod, Key, 1) of
|
||||||
true ->
|
true ->
|
||||||
Val = to_s(apply(Mod, Key, [Ctx])),
|
Val = to_s(Mod:Key(Ctx)),
|
||||||
% io:format("From Mod/1 {~p, ~p}~n", [Key, Val]),
|
% io:format("From Mod/1 {~p, ~p}~n", [Key, Val]),
|
||||||
Val;
|
Val;
|
||||||
false ->
|
false ->
|
||||||
case erlang:function_exported(Mod, Key, 0) of
|
case erlang:function_exported(Mod, Key, 0) of
|
||||||
true ->
|
true ->
|
||||||
Val = to_s(apply(Mod, Key, [])),
|
Val = to_s(Mod:Key()),
|
||||||
% io:format("From Mod/0 {~p, ~p}~n", [Key, Val]),
|
% io:format("From Mod/0 {~p, ~p}~n", [Key, Val]),
|
||||||
Val;
|
Val;
|
||||||
false ->
|
false ->
|
||||||
|
|
|
@ -63,7 +63,7 @@ is_app_dir(Dir) ->
|
||||||
is_app_src(Filename) ->
|
is_app_src(Filename) ->
|
||||||
%% If removing the extension .app.src yields a shorter name,
|
%% If removing the extension .app.src yields a shorter name,
|
||||||
%% this is an .app.src file.
|
%% this is an .app.src file.
|
||||||
Filename /= filename:rootname(Filename, ".app.src").
|
Filename =/= filename:rootname(Filename, ".app.src").
|
||||||
|
|
||||||
app_src_to_app(Filename) ->
|
app_src_to_app(Filename) ->
|
||||||
filename:join("ebin", filename:basename(Filename, ".app.src") ++ ".app").
|
filename:join("ebin", filename:basename(Filename, ".app.src") ++ ".app").
|
||||||
|
@ -101,14 +101,15 @@ app_vsn(AppFile) ->
|
||||||
%% ===================================================================
|
%% ===================================================================
|
||||||
|
|
||||||
load_app_file(Filename) ->
|
load_app_file(Filename) ->
|
||||||
case erlang:get({app_file, Filename}) of
|
AppFile = {app_file, Filename},
|
||||||
|
case erlang:get(AppFile) of
|
||||||
undefined ->
|
undefined ->
|
||||||
case file:consult(Filename) of
|
case file:consult(Filename) of
|
||||||
{ok, [{application, AppName, AppData}]} ->
|
{ok, [{application, AppName, AppData}]} ->
|
||||||
erlang:put({app_file, Filename}, {AppName, AppData}),
|
erlang:put(AppFile, {AppName, AppData}),
|
||||||
{ok, AppName, AppData};
|
{ok, AppName, AppData};
|
||||||
{error, Reason} ->
|
{error, _} = Error ->
|
||||||
{error, Reason};
|
Error;
|
||||||
Other ->
|
Other ->
|
||||||
{error, {unexpected_terms, Other}}
|
{error, {unexpected_terms, Other}}
|
||||||
end;
|
end;
|
||||||
|
|
|
@ -66,7 +66,7 @@ run(Config, FirstFiles, SourceDir, SourceExt, TargetDir, TargetExt,
|
||||||
|
|
||||||
%% Remove first files from found files
|
%% Remove first files from found files
|
||||||
RestFiles = [Source || Source <- FoundFiles,
|
RestFiles = [Source || Source <- FoundFiles,
|
||||||
lists:member(Source, FirstFiles) == false],
|
not lists:member(Source, FirstFiles)],
|
||||||
|
|
||||||
%% Check opts for flag indicating that compile should check lastmod
|
%% Check opts for flag indicating that compile should check lastmod
|
||||||
CheckLastMod = proplists:get_bool(check_last_mod, Opts),
|
CheckLastMod = proplists:get_bool(check_last_mod, Opts),
|
||||||
|
|
|
@ -96,12 +96,7 @@ get_global(Key, Default) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
is_verbose() ->
|
is_verbose() ->
|
||||||
case get_global(verbose, "0") of
|
get_global(verbose, "0") =:= "1".
|
||||||
"1" ->
|
|
||||||
true;
|
|
||||||
_ ->
|
|
||||||
false
|
|
||||||
end.
|
|
||||||
|
|
||||||
get_jobs() ->
|
get_jobs() ->
|
||||||
get_global(jobs, 3).
|
get_global(jobs, 3).
|
||||||
|
|
|
@ -86,10 +86,11 @@ run(RawArgs) ->
|
||||||
process_commands(CommandAtoms).
|
process_commands(CommandAtoms).
|
||||||
|
|
||||||
skip_dir(Dir) ->
|
skip_dir(Dir) ->
|
||||||
case erlang:get({skip_dir, Dir}) of
|
SkipDir = {skip_dir, Dir},
|
||||||
|
case erlang:get(SkipDir) of
|
||||||
undefined ->
|
undefined ->
|
||||||
?DEBUG("Adding skip dir: ~s\n", [Dir]),
|
?DEBUG("Adding skip dir: ~s\n", [Dir]),
|
||||||
erlang:put({skip_dir, Dir}, true);
|
erlang:put(SkipDir, true);
|
||||||
true ->
|
true ->
|
||||||
ok
|
ok
|
||||||
end.
|
end.
|
||||||
|
@ -465,7 +466,7 @@ restore_code_path(no_change) ->
|
||||||
restore_code_path({old, Path}) ->
|
restore_code_path({old, Path}) ->
|
||||||
%% Verify that all of the paths still exist -- some dynamically add paths
|
%% Verify that all of the paths still exist -- some dynamically add paths
|
||||||
%% can get blown away during clean.
|
%% can get blown away during clean.
|
||||||
true = code:set_path(lists:filter(fun filelib:is_file/1, Path)),
|
true = code:set_path([F || F <- Path, filelib:is_file(F)]),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
|
||||||
|
@ -495,8 +496,8 @@ run_modules([Module | Rest], Command, Config, File) ->
|
||||||
case Module:Command(Config, File) of
|
case Module:Command(Config, File) of
|
||||||
ok ->
|
ok ->
|
||||||
run_modules(Rest, Command, Config, File);
|
run_modules(Rest, Command, Config, File);
|
||||||
{error, Reason} ->
|
{error, _} = Error ->
|
||||||
{error, Reason}
|
Error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -201,11 +201,8 @@ delete_dep(D) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
require_source_engine(Source) ->
|
require_source_engine(Source) ->
|
||||||
case source_engine_avail(Source) of
|
true = source_engine_avail(Source),
|
||||||
true ->
|
ok.
|
||||||
ok
|
|
||||||
end.
|
|
||||||
|
|
||||||
|
|
||||||
is_app_available(App, VsnRegex) ->
|
is_app_available(App, VsnRegex) ->
|
||||||
case code:lib_dir(App) of
|
case code:lib_dir(App) of
|
||||||
|
|
|
@ -142,8 +142,8 @@ dialyze(Config, File) ->
|
||||||
%% @spec app_dirs(Apps::[atom()]) -> [string()]
|
%% @spec app_dirs(Apps::[atom()]) -> [string()]
|
||||||
-spec app_dirs(Apps::[atom()]) -> [string()].
|
-spec app_dirs(Apps::[atom()]) -> [string()].
|
||||||
app_dirs(Apps) ->
|
app_dirs(Apps) ->
|
||||||
[filename:join(Path, "ebin") ||
|
[filename:join(Path, "ebin")
|
||||||
Path <- lists:map(fun(App) -> code:lib_dir(App) end, Apps), erlang:is_list(Path)].
|
|| Path <- [code:lib_dir(App) || App <- Apps], erlang:is_list(Path)].
|
||||||
|
|
||||||
%% @doc Render the warnings on the console.
|
%% @doc Render the warnings on the console.
|
||||||
%% @spec output_warnings(Warnings::[warning()]) -> 'ok'
|
%% @spec output_warnings(Warnings::[warning()]) -> 'ok'
|
||||||
|
|
|
@ -104,11 +104,11 @@ doterl_compile(Config, OutDir, MoreSources) ->
|
||||||
ErlOpts = filter_defines(rebar_config:get(Config, erl_opts, []), []),
|
ErlOpts = filter_defines(rebar_config:get(Config, erl_opts, []), []),
|
||||||
?DEBUG("erl_opts ~p~n",[ErlOpts]),
|
?DEBUG("erl_opts ~p~n",[ErlOpts]),
|
||||||
%% Support the src_dirs option allowing multiple directories to
|
%% Support the src_dirs option allowing multiple directories to
|
||||||
%% contain erlang source. This might be used, for example, should eunit tests be
|
%% contain erlang source. This might be used, for example, should
|
||||||
%% separated from the core application source.
|
%% eunit tests be separated from the core application source.
|
||||||
SrcDirs = src_dirs(proplists:append_values(src_dirs, ErlOpts)),
|
SrcDirs = src_dirs(proplists:append_values(src_dirs, ErlOpts)),
|
||||||
RestErls = [Source || Source <- gather_src(SrcDirs, []) ++ MoreSources,
|
RestErls = [Source || Source <- gather_src(SrcDirs, []) ++ MoreSources,
|
||||||
lists:member(Source, FirstErls) == false],
|
not lists:member(Source, FirstErls)],
|
||||||
|
|
||||||
% Split RestErls so that parse_transforms and behaviours are instead added
|
% Split RestErls so that parse_transforms and behaviours are instead added
|
||||||
% to erl_first_files, parse transforms first.
|
% to erl_first_files, parse transforms first.
|
||||||
|
@ -131,8 +131,8 @@ doterl_compile(Config, OutDir, MoreSources) ->
|
||||||
CurrPath = code:get_path(),
|
CurrPath = code:get_path(),
|
||||||
true = code:add_path("ebin"),
|
true = code:add_path("ebin"),
|
||||||
rebar_base_compiler:run(Config, NewFirstErls, OtherErls,
|
rebar_base_compiler:run(Config, NewFirstErls, OtherErls,
|
||||||
fun(S, C) -> internal_erl_compile(S, C, OutDir,
|
fun(S, C) ->
|
||||||
ErlOpts)
|
internal_erl_compile(S, C, OutDir, ErlOpts)
|
||||||
end),
|
end),
|
||||||
true = code:set_path(CurrPath),
|
true = code:set_path(CurrPath),
|
||||||
ok.
|
ok.
|
||||||
|
|
|
@ -149,18 +149,14 @@ module_name(Target) ->
|
||||||
|
|
||||||
needs_compile(Source, Target, Config) ->
|
needs_compile(Source, Target, Config) ->
|
||||||
LM = filelib:last_modified(Target),
|
LM = filelib:last_modified(Target),
|
||||||
case LM < filelib:last_modified(Source) of
|
LM < filelib:last_modified(Source) orelse
|
||||||
true -> true;
|
|
||||||
false ->
|
|
||||||
lists:any(fun(D) -> LM < filelib:last_modified(D) end,
|
lists:any(fun(D) -> LM < filelib:last_modified(D) end,
|
||||||
referenced_dtls(Source, Config))
|
referenced_dtls(Source, Config)).
|
||||||
end.
|
|
||||||
|
|
||||||
referenced_dtls(Source, Config) ->
|
referenced_dtls(Source, Config) ->
|
||||||
Set = referenced_dtls1([Source], Config,
|
Set = referenced_dtls1([Source], Config,
|
||||||
sets:add_element(Source, sets:new())),
|
sets:add_element(Source, sets:new())),
|
||||||
Final = sets:to_list(sets:del_element(Source, Set)),
|
sets:to_list(sets:del_element(Source, Set)).
|
||||||
Final.
|
|
||||||
|
|
||||||
referenced_dtls1(Step, Config, Seen) ->
|
referenced_dtls1(Step, Config, Seen) ->
|
||||||
DtlOpts = erlydtl_opts(Config),
|
DtlOpts = erlydtl_opts(Config),
|
||||||
|
@ -173,7 +169,7 @@ referenced_dtls1(Step, Config, Seen) ->
|
||||||
|| F <- Step]),
|
|| F <- Step]),
|
||||||
DocRoot = option(doc_root, DtlOpts),
|
DocRoot = option(doc_root, DtlOpts),
|
||||||
WithPaths = [ filename:join([DocRoot, F]) || F <- AllRefs ],
|
WithPaths = [ filename:join([DocRoot, F]) || F <- AllRefs ],
|
||||||
Existing = lists:filter(fun filelib:is_file/1, WithPaths),
|
Existing = [F || F <- WithPaths, filelib:is_file(F)],
|
||||||
New = sets:subtract(sets:from_list(Existing), Seen),
|
New = sets:subtract(sets:from_list(Existing), Seen),
|
||||||
case sets:size(New) of
|
case sets:size(New) of
|
||||||
0 -> Seen;
|
0 -> Seen;
|
||||||
|
|
|
@ -286,9 +286,8 @@ is_eunitized(Mod) ->
|
||||||
has_header(Mod, "include/eunit.hrl").
|
has_header(Mod, "include/eunit.hrl").
|
||||||
|
|
||||||
has_eunit_test_fun(Mod) ->
|
has_eunit_test_fun(Mod) ->
|
||||||
length([F || {exports, Funs} <- Mod:module_info(),
|
[F || {exports, Funs} <- Mod:module_info(),
|
||||||
{F, 0} <- Funs,
|
{F, 0} <- Funs, F =:= test] =/= [].
|
||||||
F == test]) =/= 0.
|
|
||||||
|
|
||||||
has_header(Mod, Header) ->
|
has_header(Mod, Header) ->
|
||||||
Mod1 = case code:which(Mod) of
|
Mod1 = case code:which(Mod) of
|
||||||
|
@ -300,8 +299,8 @@ has_header(Mod, Header) ->
|
||||||
L -> L
|
L -> L
|
||||||
end,
|
end,
|
||||||
{ok, {_, [{abstract_code, {_, AC}}]}} = beam_lib:chunks(Mod1, [abstract_code]),
|
{ok, {_, [{abstract_code, {_, AC}}]}} = beam_lib:chunks(Mod1, [abstract_code]),
|
||||||
length([F || {attribute, 1, file, {F, 1}} <- AC,
|
[F || {attribute, 1, file, {F, 1}} <- AC,
|
||||||
string:str(F, Header) =/= 0]) =/= 0.
|
string:str(F, Header) =/= 0] =/= [].
|
||||||
|
|
||||||
align_notcovered_count(Module, Covered, NotCovered, false) ->
|
align_notcovered_count(Module, Covered, NotCovered, false) ->
|
||||||
{Module, Covered, NotCovered};
|
{Module, Covered, NotCovered};
|
||||||
|
|
|
@ -108,18 +108,14 @@ do_compile(Source, _Target, Config) ->
|
||||||
|
|
||||||
needs_compile(Source, Target, Config) ->
|
needs_compile(Source, Target, Config) ->
|
||||||
LM = filelib:last_modified(Target),
|
LM = filelib:last_modified(Target),
|
||||||
case LM < filelib:last_modified(Source) of
|
LM < filelib:last_modified(Source) orelse
|
||||||
true -> true;
|
|
||||||
false ->
|
|
||||||
lists:any(fun(D) -> LM < filelib:last_modified(D) end,
|
lists:any(fun(D) -> LM < filelib:last_modified(D) end,
|
||||||
referenced_pegs(Source, Config))
|
referenced_pegs(Source, Config)).
|
||||||
end.
|
|
||||||
|
|
||||||
referenced_pegs(Source, Config) ->
|
referenced_pegs(Source, Config) ->
|
||||||
Set = referenced_pegs1([Source], Config,
|
Set = referenced_pegs1([Source], Config,
|
||||||
sets:add_element(Source, sets:new())),
|
sets:add_element(Source, sets:new())),
|
||||||
Final = sets:to_list(sets:del_element(Source, Set)),
|
sets:to_list(sets:del_element(Source, Set)).
|
||||||
Final.
|
|
||||||
|
|
||||||
referenced_pegs1(Step, Config, Seen) ->
|
referenced_pegs1(Step, Config, Seen) ->
|
||||||
NeoOpts = neotoma_opts(Config),
|
NeoOpts = neotoma_opts(Config),
|
||||||
|
@ -132,7 +128,7 @@ referenced_pegs1(Step, Config, Seen) ->
|
||||||
|| F <- Step]),
|
|| F <- Step]),
|
||||||
DocRoot = option(doc_root, NeoOpts),
|
DocRoot = option(doc_root, NeoOpts),
|
||||||
WithPaths = [ filename:join([DocRoot, F]) || F <- AllRefs ],
|
WithPaths = [ filename:join([DocRoot, F]) || F <- AllRefs ],
|
||||||
Existing = lists:filter(fun filelib:is_file/1, WithPaths),
|
Existing = [F || F <- WithPaths, filelib:is_file(F)],
|
||||||
New = sets:subtract(sets:from_list(Existing), Seen),
|
New = sets:subtract(sets:from_list(Existing), Seen),
|
||||||
case sets:size(New) of
|
case sets:size(New) of
|
||||||
0 -> Seen;
|
0 -> Seen;
|
||||||
|
|
|
@ -137,9 +137,8 @@ expand_sources([Spec | Rest], Acc) ->
|
||||||
expand_sources(Rest, Acc2).
|
expand_sources(Rest, Acc2).
|
||||||
|
|
||||||
expand_objects(Sources) ->
|
expand_objects(Sources) ->
|
||||||
lists:map(fun(File) ->
|
[filename:join([filename:dirname(F), filename:basename(F) ++ ".o"])
|
||||||
filename:join([filename:dirname(File),filename:basename(File) ++ ".o"])
|
|| F <- Sources].
|
||||||
end, Sources).
|
|
||||||
|
|
||||||
run_precompile_hook(Config, Env) ->
|
run_precompile_hook(Config, Env) ->
|
||||||
case rebar_config:get(Config, port_pre_script, undefined) of
|
case rebar_config:get(Config, port_pre_script, undefined) of
|
||||||
|
|
|
@ -74,13 +74,7 @@ clean(_Config, _AppFile) ->
|
||||||
%% ===================================================================
|
%% ===================================================================
|
||||||
|
|
||||||
protobuffs_is_present() ->
|
protobuffs_is_present() ->
|
||||||
case code:which(protobuffs_compile) of
|
code:which(protobuffs_compile) =/= non_existing.
|
||||||
non_existing ->
|
|
||||||
false;
|
|
||||||
_ ->
|
|
||||||
true
|
|
||||||
end.
|
|
||||||
|
|
||||||
|
|
||||||
beam_file(Proto) ->
|
beam_file(Proto) ->
|
||||||
filename:basename(Proto, ".proto") ++ "_pb.beam".
|
filename:basename(Proto, ".proto") ++ "_pb.beam".
|
||||||
|
|
|
@ -106,9 +106,9 @@ load_config(ReltoolFile) ->
|
||||||
%% can't run reltool.
|
%% can't run reltool.
|
||||||
%%
|
%%
|
||||||
sys_tuple(ReltoolConfig) ->
|
sys_tuple(ReltoolConfig) ->
|
||||||
case lists:keysearch(sys, 1, ReltoolConfig) of
|
case lists:keyfind(sys, 1, ReltoolConfig) of
|
||||||
{value, {sys, Data}} ->
|
{sys, _} = SysTuple ->
|
||||||
{sys, Data};
|
SysTuple;
|
||||||
false ->
|
false ->
|
||||||
?ABORT("Failed to find {sys, [...]} tuple in reltool.config.", [])
|
?ABORT("Failed to find {sys, [...]} tuple in reltool.config.", [])
|
||||||
end.
|
end.
|
||||||
|
@ -120,13 +120,13 @@ sys_tuple(ReltoolConfig) ->
|
||||||
target_dir(ReltoolConfig) ->
|
target_dir(ReltoolConfig) ->
|
||||||
case rebar_config:get_global(target_dir, undefined) of
|
case rebar_config:get_global(target_dir, undefined) of
|
||||||
undefined ->
|
undefined ->
|
||||||
case lists:keysearch(target_dir, 1, ReltoolConfig) of
|
case lists:keyfind(target_dir, 1, ReltoolConfig) of
|
||||||
{value, {target_dir, TargetDir}} ->
|
{target_dir, TargetDir} ->
|
||||||
filename:absname(TargetDir);
|
filename:absname(TargetDir);
|
||||||
false ->
|
false ->
|
||||||
{sys, SysInfo} = sys_tuple(ReltoolConfig),
|
{sys, SysInfo} = sys_tuple(ReltoolConfig),
|
||||||
case lists:keysearch(rel, 1, SysInfo) of
|
case lists:keyfind(rel, 1, SysInfo) of
|
||||||
{value, {rel, Name, _Vsn, _Apps}} ->
|
{rel, Name, _Vsn, _Apps} ->
|
||||||
filename:absname(Name);
|
filename:absname(Name);
|
||||||
false ->
|
false ->
|
||||||
filename:absname("target")
|
filename:absname("target")
|
||||||
|
@ -144,8 +144,8 @@ target_dir(ReltoolConfig) ->
|
||||||
overlay_vars(ReltoolConfig) ->
|
overlay_vars(ReltoolConfig) ->
|
||||||
case rebar_config:get_global(overlay_vars, undefined) of
|
case rebar_config:get_global(overlay_vars, undefined) of
|
||||||
undefined ->
|
undefined ->
|
||||||
case lists:keysearch(overlay_vars, 1, ReltoolConfig) of
|
case lists:keyfind(overlay_vars, 1, ReltoolConfig) of
|
||||||
{value, {overlay_vars, File}} ->
|
{overlay_vars, File} ->
|
||||||
File;
|
File;
|
||||||
false ->
|
false ->
|
||||||
undefined
|
undefined
|
||||||
|
@ -156,8 +156,10 @@ overlay_vars(ReltoolConfig) ->
|
||||||
|
|
||||||
|
|
||||||
validate_rel_apps(ReltoolServer, {sys, ReltoolConfig}) ->
|
validate_rel_apps(ReltoolServer, {sys, ReltoolConfig}) ->
|
||||||
case lists:keysearch(rel, 1, ReltoolConfig) of
|
case lists:keyfind(rel, 1, ReltoolConfig) of
|
||||||
{value, {rel, _Name, _Vsn, Apps}} ->
|
false ->
|
||||||
|
ok;
|
||||||
|
{rel, _Name, _Vsn, Apps} ->
|
||||||
%% Identify all the apps that do NOT exist, based on what's available
|
%% Identify all the apps that do NOT exist, based on what's available
|
||||||
%% from the reltool server
|
%% from the reltool server
|
||||||
Missing = lists:sort([App || App <- Apps,
|
Missing = lists:sort([App || App <- Apps,
|
||||||
|
@ -168,11 +170,9 @@ validate_rel_apps(ReltoolServer, {sys, ReltoolConfig}) ->
|
||||||
_ ->
|
_ ->
|
||||||
?ABORT("Apps in {rel, ...} section not found by reltool: ~p\n", [Missing])
|
?ABORT("Apps in {rel, ...} section not found by reltool: ~p\n", [Missing])
|
||||||
end;
|
end;
|
||||||
{value, Rel} ->
|
Rel ->
|
||||||
%% Invalid release format!
|
%% Invalid release format!
|
||||||
?ABORT("Invalid {rel, ...} section in reltools.config: ~p\n", [Rel]);
|
?ABORT("Invalid {rel, ...} section in reltools.config: ~p\n", [Rel])
|
||||||
false ->
|
|
||||||
ok
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
app_exists(App, Server) when is_atom(App) ->
|
app_exists(App, Server) when is_atom(App) ->
|
||||||
|
@ -330,9 +330,10 @@ execute_overlay([Other | _Rest], _Vars, _BaseDir, _TargetDir) ->
|
||||||
%% Render a binary to a string, using mustache and the specified context
|
%% Render a binary to a string, using mustache and the specified context
|
||||||
%%
|
%%
|
||||||
render(Bin, Context) ->
|
render(Bin, Context) ->
|
||||||
|
ReOpts = [global, {return, list}],
|
||||||
%% Be sure to escape any double-quotes before rendering...
|
%% Be sure to escape any double-quotes before rendering...
|
||||||
Str0 = re:replace(Bin, "\\\\", "\\\\\\", [global, {return, list}]),
|
Str0 = re:replace(Bin, "\\\\", "\\\\\\", ReOpts),
|
||||||
Str1 = re:replace(Str0, "\"", "\\\\\"", [global, {return,list}]),
|
Str1 = re:replace(Str0, "\"", "\\\\\"", ReOpts),
|
||||||
mustache:render(Str1, Context).
|
mustache:render(Str1, Context).
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -84,8 +84,8 @@ create(_Config, _) ->
|
||||||
%% Load the template definition as is and get the list of variables the
|
%% Load the template definition as is and get the list of variables the
|
||||||
%% template requires.
|
%% template requires.
|
||||||
TemplateTerms = consult(load_file(Type, Template)),
|
TemplateTerms = consult(load_file(Type, Template)),
|
||||||
case lists:keysearch(variables, 1, TemplateTerms) of
|
case lists:keyfind(variables, 1, TemplateTerms) of
|
||||||
{value, {variables, Vars}} ->
|
{variables, Vars} ->
|
||||||
case parse_vars(Vars, dict:new()) of
|
case parse_vars(Vars, dict:new()) of
|
||||||
{error, Entry} ->
|
{error, Entry} ->
|
||||||
Context0 = undefined,
|
Context0 = undefined,
|
||||||
|
@ -270,8 +270,8 @@ write_file(Output, Data, Force) ->
|
||||||
%% Execute each instruction in a template definition file.
|
%% Execute each instruction in a template definition file.
|
||||||
%%
|
%%
|
||||||
execute_template([], _TemplateType, _TemplateName, _Context, _Force, ExistingFiles) ->
|
execute_template([], _TemplateType, _TemplateName, _Context, _Force, ExistingFiles) ->
|
||||||
case length(ExistingFiles) of
|
case ExistingFiles of
|
||||||
0 ->
|
[] ->
|
||||||
ok;
|
ok;
|
||||||
_ ->
|
_ ->
|
||||||
Msg = lists:flatten([io_lib:format("\t* ~p~n", [F]) || F <- lists:reverse(ExistingFiles)]),
|
Msg = lists:flatten([io_lib:format("\t* ~p~n", [F]) || F <- lists:reverse(ExistingFiles)]),
|
||||||
|
|
|
@ -205,6 +205,6 @@ emulate_escript_foldl(Fun, Acc, File) ->
|
||||||
{archive, ArchiveBin} ->
|
{archive, ArchiveBin} ->
|
||||||
zip:foldl(Fun, Acc, {File, ArchiveBin})
|
zip:foldl(Fun, Acc, {File, ArchiveBin})
|
||||||
end;
|
end;
|
||||||
{error, Reason} ->
|
{error, _} = Error ->
|
||||||
{error, Reason}
|
Error
|
||||||
end.
|
end.
|
||||||
|
|
Loading…
Reference in a new issue