diff --git a/apps/rebar/src/rebar_compiler_erl.erl b/apps/rebar/src/rebar_compiler_erl.erl index 294a37146..98e365c94 100644 --- a/apps/rebar/src/rebar_compiler_erl.erl +++ b/apps/rebar/src/rebar_compiler_erl.erl @@ -115,7 +115,7 @@ dependencies(Source, _SourceDir, Dirs, DepOpts) -> %% TODO: check for core transforms? {_MissIncl, _MissInclLib} =/= {[],[]} andalso ?DIAGNOSTIC("Missing: ~p", [{_MissIncl, _MissInclLib}]), - lists:filtermap( + rebar_utils:filtermap( fun (Mod) -> rebar_compiler_epp:resolve_source(Mod, Dirs) end, OptPTrans ++ PTrans ++ Behaviours) ++ AbsIncls catch diff --git a/apps/rebar/src/rebar_plugins.erl b/apps/rebar/src/rebar_plugins.erl index 9b2f50211..ad8211a94 100644 --- a/apps/rebar/src/rebar_plugins.erl +++ b/apps/rebar/src/rebar_plugins.erl @@ -78,7 +78,7 @@ install(State, AppInfo) -> filter_existing_plugins(Plugins, State) -> PluginNames = lists:zip(Plugins, rebar_state:deps_names(Plugins)), AllPlugins = rebar_state:all_plugin_deps(State), - lists:filtermap(fun({Plugin, PluginName}) -> + rebar_utils:filtermap(fun({Plugin, PluginName}) -> case rebar_app_utils:find(PluginName, AllPlugins) of {ok, _} -> false; diff --git a/apps/rebar/src/rebar_utils.erl b/apps/rebar/src/rebar_utils.erl index 2ac2a092d..f729f4941 100644 --- a/apps/rebar/src/rebar_utils.erl +++ b/apps/rebar/src/rebar_utils.erl @@ -105,22 +105,13 @@ sort_deps(Deps) -> droplast(L) -> lists:reverse(tl(lists:reverse(L))). -%% @doc filtermap takes in a function that is either or both -%% a predicate and a map, and returns the matching and valid elements. +%% @doc wrapper around lists:filtermap/2 -spec filtermap(F, [In]) -> [Out] when F :: fun((In) -> boolean() | {true, Out}), In :: term(), Out :: term(). -filtermap(F, [Hd|Tail]) -> - case F(Hd) of - true -> - [Hd|filtermap(F, Tail)]; - {true,Val} -> - [Val|filtermap(F, Tail)]; - false -> - filtermap(F, Tail) - end; -filtermap(F, []) when is_function(F, 1) -> []. +filtermap(F, In) -> + lists:filtermap(F, In). is_arch(ArchRegex) -> case re:run(get_arch(), ArchRegex, [{capture, none}, unicode]) of