summaryrefslogtreecommitdiff
path: root/src/rebar_file_utils.erl
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2019-01-23 14:49:11 -0500
committerFred Hebert <mononcqc@ferd.ca>2019-01-23 14:49:11 -0500
commit92783945d5882ec91d739dcc6da9899d296f7b13 (patch)
treed82f792e1fb0e50938b7c282deb0b5913cce9430 /src/rebar_file_utils.erl
parent84cb7c3baa213d1a7e9af92379c59e38c1e282e6 (diff)
parent7a9f88790ea4799d3b6c3ec0a6e43f6827540177 (diff)
Merge branch 'working-systests-on-darwin' of https://github.com/starbelly/rebar3 into starbelly-working-systests-on-darwin
Diffstat (limited to 'src/rebar_file_utils.erl')
-rw-r--r--src/rebar_file_utils.erl17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/rebar_file_utils.erl b/src/rebar_file_utils.erl
index a51a557..5b6164a 100644
--- a/src/rebar_file_utils.erl
+++ b/src/rebar_file_utils.erl
@@ -189,16 +189,27 @@ 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,
% 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),