aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rlx_cmd_args.erl5
-rw-r--r--src/rlx_prv_config.erl2
-rw-r--r--src/rlx_util.erl20
3 files changed, 23 insertions, 4 deletions
diff --git a/src/rlx_cmd_args.erl b/src/rlx_cmd_args.erl
index f592474..d2402ce 100644
--- a/src/rlx_cmd_args.erl
+++ b/src/rlx_cmd_args.erl
@@ -223,11 +223,12 @@ create_output_dir(Opts, Acc) ->
create_lib_dirs(Opts, Acc) ->
Dirs = proplists:get_all_values(lib_dir, Opts) ++
proplists:get_value(lib_dirs, Opts, []),
- case check_lib_dirs(Dirs) of
+ ExpDirs = rlx_util:wildcard_paths(Dirs),
+ case check_lib_dirs(ExpDirs) of
Error = {error, _} ->
Error;
ok ->
- create_root_dir(Opts, [{lib_dirs, [filename:absname(Dir) || Dir <- Dirs]} | Acc])
+ create_root_dir(Opts, [{lib_dirs, ExpDirs} | Acc])
end.
-spec create_root_dir([getopt:option()], rlx_state:cmd_args()) ->
diff --git a/src/rlx_prv_config.erl b/src/rlx_prv_config.erl
index 19aa576..aa2e79c 100644
--- a/src/rlx_prv_config.erl
+++ b/src/rlx_prv_config.erl
@@ -129,7 +129,7 @@ load_terms({paths, Paths}, {ok, State}) ->
load_terms({lib_dirs, Dirs}, {ok, State}) ->
State2 =
rlx_state:add_lib_dirs(State,
- [list_to_binary(filename:absname(Dir)) || Dir <- Dirs]),
+ [list_to_binary(Dir) || Dir <- rlx_util:wildcard_paths(Dirs)]),
{ok, State2};
load_terms({providers, Providers0}, {ok, State0}) ->
Providers1 = gen_providers(Providers0, State0),
diff --git a/src/rlx_util.erl b/src/rlx_util.erl
index 53e9122..48e2ee1 100644
--- a/src/rlx_util.erl
+++ b/src/rlx_util.erl
@@ -28,7 +28,8 @@
is_error/1,
error_reason/1,
indent/1,
- optional_to_string/1]).
+ optional_to_string/1,
+ wildcard_paths/1]).
-define(ONE_LEVEL_INDENT, " ").
%%============================================================================
@@ -96,6 +97,23 @@ optional_to_string(undefined) ->
optional_to_string(Value) when is_list(Value) ->
Value.
+%% @doc expand wildcards and names in the given paths
+-spec wildcard_paths([file:filename_all()]) -> [string()].
+wildcard_paths(Paths) ->
+ [filename:absname(Expanded) || Path <- Paths, Expanded <- wildcard(Path)].
+
+%% In case the given directory does not expand,
+%% we return it back in a list so we trigger the
+%% proper error reportings.
+-spec wildcard(file:filename_all()) -> [string()].
+wildcard(Path) when is_binary(Path) ->
+ wildcard(binary_to_list(Path));
+wildcard(Path) when is_list(Path) ->
+ case filelib:wildcard(Path) of
+ [] -> [Path];
+ Paths -> Paths
+ end.
+
%%%===================================================================
%%% Test Functions
%%%===================================================================