summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralisdair sullivan <alisdairsullivan@yahoo.ca>2016-01-13 20:39:43 -0800
committeralisdair sullivan <alisdairsullivan@yahoo.ca>2016-01-13 20:39:43 -0800
commit4e0de56b90b318e580884daf1d8f56ab3944b914 (patch)
treedeb306a86c7ce18ea7160ed28f0631e5a9e4b42b
parent81efc493e1ad65da4c321b0569b2bb068c3bb4db (diff)
check at runtime instead of compile time for presence of `file:list_dir_all/1`
this is slower than the compile time check but i guess packaging rebars with repos is still a thing and i think only the eunit and ct providers call it anyways
-rw-r--r--rebar.config1
-rw-r--r--src/rebar_utils.erl13
2 files changed, 8 insertions, 6 deletions
diff --git a/rebar.config b/rebar.config
index a720d98..d8f9bbd 100644
--- a/rebar.config
+++ b/rebar.config
@@ -20,7 +20,6 @@
{"rebar/priv/templates/*", "_build/default/lib/"}]}.
{erl_opts, [{platform_define, "^[0-9]+", namespaced_types},
- {platform_define, "^R1[4|5]", no_list_dir_all},
no_debug_info,
warnings_as_errors]}.
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl
index 746c57a..07bf789 100644
--- a/src/rebar_utils.erl
+++ b/src/rebar_utils.erl
@@ -828,8 +828,11 @@ info_useless(Old, New) ->
not lists:member(Name, New)],
ok.
--ifdef(no_list_dir_all).
-list_dir(Dir) -> file:list_dir(Dir).
--else.
-list_dir(Dir) -> file:list_dir_all(Dir).
--endif.
+list_dir(Dir) ->
+ %% `list_dir_all` returns raw files which are unsupported
+ %% prior to R16 so just fall back to `list_dir` if running
+ %% on an earlier vm
+ case erlang:function_exported(file, list_dir_all, 1) of
+ true -> file:list_dir_all(Dir);
+ false -> file:list_dir(Dir)
+ end.