diff options
Diffstat (limited to 'src/rebar_app_utils.erl')
-rw-r--r-- | src/rebar_app_utils.erl | 68 |
1 files changed, 17 insertions, 51 deletions
diff --git a/src/rebar_app_utils.erl b/src/rebar_app_utils.erl index 1c53743..8fc3df8 100644 --- a/src/rebar_app_utils.erl +++ b/src/rebar_app_utils.erl @@ -26,13 +26,14 @@ %% ------------------------------------------------------------------- -module(rebar_app_utils). --export([is_app_dir/0, is_app_dir/1, +-export([find/2, + find/3, + is_app_dir/0, is_app_dir/1, is_app_src/1, app_src_to_app/1, app_name/2, app_applications/2, - app_vsn/2, - is_skipped_app/2]). + app_vsn/2]). -export([load_app_file/2]). % TEMPORARY @@ -42,9 +43,22 @@ %% Public API %% =================================================================== +-spec find(binary(), [rebar_app_info:t()]) -> {ok, rebar_app_info:t()} | error. +find(Name, Apps) -> + ec_lists:find(fun(App) -> rebar_app_info:name(App) =:= Name end, Apps). + +-spec find(binary(), binary(), [rebar_app_info:t()]) -> {ok, rebar_app_info:t()} | error. +find(Name, Vsn, Apps) -> + ec_lists:find(fun(App) -> + rebar_app_info:name(App) =:= Name + andalso rebar_app_info:original_vsn(App) =:= Vsn + end, Apps). + +-spec is_app_dir() -> {true, file:name()} | false. is_app_dir() -> is_app_dir(rebar_utils:get_cwd()). +-spec is_app_dir(file:name()) -> {true, file:name()} | false. is_app_dir(Dir) -> SrcDir = filename:join([Dir, "src"]), AppSrc = filename:join([SrcDir, "*.app.src"]), @@ -109,30 +123,6 @@ app_vsn(Config, AppFile) -> [AppFile, Reason]) end. -is_skipped_app(Config, AppFile) -> - {Config1, ThisApp} = app_name(Config, AppFile), - %% Check for apps global parameter; this is a comma-delimited list - %% of apps on which we want to run commands - Skipped = - case get_apps(Config) of - undefined -> - %% No apps parameter specified, check the skip_apps list.. - case get_skip_apps(Config) of - undefined -> - %% No skip_apps list, run everything.. - false; - SkipApps -> - TargetApps = [list_to_atom(A) || - A <- string:tokens(SkipApps, ",")], - is_skipped(ThisApp, TargetApps) - end; - Apps -> - %% run only selected apps - TargetApps = [list_to_atom(A) || A <- string:tokens(Apps, ",")], - is_selected(ThisApp, TargetApps) - end, - {Config1, Skipped}. - %% =================================================================== %% Internal functions %% =================================================================== @@ -176,27 +166,3 @@ get_value(Key, AppInfo, AppFile) -> Value -> Value end. - -%% apps= for selecting apps -is_selected(ThisApp, TargetApps) -> - case lists:member(ThisApp, TargetApps) of - false -> - {true, ThisApp}; - true -> - false - end. - -%% skip_apps= for filtering apps -is_skipped(ThisApp, TargetApps) -> - case lists:member(ThisApp, TargetApps) of - false -> - false; - true -> - {true, ThisApp} - end. - -get_apps(Config) -> - rebar_config:get_global(Config, apps, undefined). - -get_skip_apps(Config) -> - rebar_config:get_global(Config, skip_apps, undefined). |