mirror of
https://github.com/correl/rebar.git
synced 2024-11-23 19:19:54 +00:00
Make sure to apply any file perms when doing a templated file
This commit is contained in:
parent
f3039c7a87
commit
127483f32b
1 changed files with 8 additions and 1 deletions
|
@ -261,11 +261,13 @@ execute_overlay([{copy, In, Out} | Rest], Vars, BaseDir, TargetDir) ->
|
||||||
rebar_utils:sh(?FMT("cp -R ~p ~p", [InFile, OutFile]), []),
|
rebar_utils:sh(?FMT("cp -R ~p ~p", [InFile, OutFile]), []),
|
||||||
execute_overlay(Rest, Vars, BaseDir, TargetDir);
|
execute_overlay(Rest, Vars, BaseDir, TargetDir);
|
||||||
execute_overlay([{template, In, Out} | Rest], Vars, BaseDir, TargetDir) ->
|
execute_overlay([{template, In, Out} | Rest], Vars, BaseDir, TargetDir) ->
|
||||||
{ok, InFileData} = file:read_file(render(filename:join(BaseDir, In), Vars)),
|
InFile = render(filename:join(BaseDir, In), Vars),
|
||||||
|
{ok, InFileData} = file:read_file(InFile),
|
||||||
OutFile = render(filename:join(TargetDir, Out), Vars),
|
OutFile = render(filename:join(TargetDir, Out), Vars),
|
||||||
ok = filelib:ensure_dir(OutFile),
|
ok = filelib:ensure_dir(OutFile),
|
||||||
case file:write_file(OutFile, render(InFileData, Vars)) of
|
case file:write_file(OutFile, render(InFileData, Vars)) of
|
||||||
ok ->
|
ok ->
|
||||||
|
ok = apply_file_info(InFile, OutFile),
|
||||||
?DEBUG("Templated ~p\n", [OutFile]),
|
?DEBUG("Templated ~p\n", [OutFile]),
|
||||||
execute_overlay(Rest, Vars, BaseDir, TargetDir);
|
execute_overlay(Rest, Vars, BaseDir, TargetDir);
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
|
@ -309,3 +311,8 @@ render(Bin, Context) ->
|
||||||
Str0 = re:replace(Bin, "\\\\", "\\\\\\", [global, {return, list}]),
|
Str0 = re:replace(Bin, "\\\\", "\\\\\\", [global, {return, list}]),
|
||||||
Str1 = re:replace(Str0, "\"", "\\\\\"", [global, {return,list}]),
|
Str1 = re:replace(Str0, "\"", "\\\\\"", [global, {return,list}]),
|
||||||
mustache:render(Str1, Context).
|
mustache:render(Str1, Context).
|
||||||
|
|
||||||
|
|
||||||
|
apply_file_info(InFile, OutFile) ->
|
||||||
|
{ok, FileInfo} = file:read_file_info(InFile),
|
||||||
|
ok = file:write_file_info(OutFile, FileInfo).
|
||||||
|
|
Loading…
Reference in a new issue