Browse Source

Merge branch 'working-systests-on-darwin' of https://github.com/starbelly/rebar3 into starbelly-working-systests-on-darwin

pull/2004/head
Fred Hebert 6 years ago
parent
commit
92783945d5
1 changed files with 14 additions and 3 deletions
  1. +14
    -3
      src/rebar_file_utils.erl

+ 14
- 3
src/rebar_file_utils.erl View File

@ -189,16 +189,27 @@ cp_r([], _Dest) ->
ok; ok;
cp_r(Sources, Dest) -> cp_r(Sources, Dest) ->
case os:type() of case os:type() of
{unix, _} ->
{unix, Os} ->
EscSources = [rebar_utils:escape_chars(Src) || Src <- Sources], EscSources = [rebar_utils:escape_chars(Src) || Src <- Sources],
SourceStr = rebar_string:join(EscSources, " "), SourceStr = rebar_string:join(EscSources, " "),
% On darwin the following cp command will cp everything inside
% target vs target and everything inside, so we chop the last char
% off if it is a '/'
Source = case {Os == darwin, lists:last(SourceStr) == 47} of
{true, true} ->
string:sub_string(SourceStr, 1, length(SourceStr) - 1);
{true, false} ->
SourceStr;
{false, _} ->
SourceStr
end,
% ensure destination exists before copying files into it % ensure destination exists before copying files into it
{ok, []} = rebar_utils:sh(?FMT("mkdir -p ~ts", {ok, []} = rebar_utils:sh(?FMT("mkdir -p ~ts",
[rebar_utils:escape_chars(Dest)]), [rebar_utils:escape_chars(Dest)]),
[{use_stdout, false}, abort_on_error]), [{use_stdout, false}, abort_on_error]),
{ok, []} = rebar_utils:sh(?FMT("cp -Rp ~ts \"~ts\"", {ok, []} = rebar_utils:sh(?FMT("cp -Rp ~ts \"~ts\"",
[SourceStr, rebar_utils:escape_double_quotes(Dest)]),
[{use_stdout, false}, abort_on_error]),
[Source, rebar_utils:escape_double_quotes(Dest)]),
[{use_stdout, true}, abort_on_error]),
ok; ok;
{win32, _} -> {win32, _} ->
lists:foreach(fun(Src) -> ok = cp_r_win32(Src,Dest) end, Sources), lists:foreach(fun(Src) -> ok = cp_r_win32(Src,Dest) end, Sources),

Loading…
Cancel
Save