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

strip trailing forward slash on recrusive cp for darwin

- fixes systests on darwin where previously the recursive cp would fail
   due to everything being copied after the last forward slash.
   Specifically, everything in  `systest/all_SUITE_data/` would be
   copied but not `all_suite_data` dir itself which the tests expected.
pull/1973/head
Bryan Paxton 6 лет назад
Родитель
Сommit
8e12c8b68e
1 измененных файлов: 15 добавлений и 3 удалений
  1. +15
    -3
      src/rebar_file_utils.erl

+ 15
- 3
src/rebar_file_utils.erl Просмотреть файл

@ -189,16 +189,28 @@ cp_r([], _Dest) ->
ok;
cp_r(Sources, Dest) ->
case os:type() of
{unix, _} ->
{unix, Os} ->
EscSources = [rebar_utils:escape_chars(Src) || Src <- Sources],
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,
EscSources = [rebar_utils:escape_chars(Src) || Src <- Sources],
% ensure destination exists before copying files into it
{ok, []} = rebar_utils:sh(?FMT("mkdir -p ~ts",
[rebar_utils:escape_chars(Dest)]),
[{use_stdout, false}, abort_on_error]),
{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;
{win32, _} ->
lists:foreach(fun(Src) -> ok = cp_r_win32(Src,Dest) end, Sources),

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