summaryrefslogtreecommitdiff
path: root/src/rebar_core.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/rebar_core.erl')
-rw-r--r--src/rebar_core.erl32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/rebar_core.erl b/src/rebar_core.erl
index b2af936..21d008a 100644
--- a/src/rebar_core.erl
+++ b/src/rebar_core.erl
@@ -40,40 +40,42 @@ process_command(State, Command) ->
not_found ->
{error, io_lib:format("Command ~p not found", [Command])};
CommandProvider ->
+ Profile = providers:profile(CommandProvider),
+ State1 = rebar_state:current_profile(State, Profile),
Opts = providers:opts(CommandProvider)++rebar3:global_option_spec_list(),
case Command of
do ->
- do(TargetProviders, State);
+ do(TargetProviders, State1);
_ ->
- case getopt:parse(Opts, rebar_state:command_args(State)) of
+ case getopt:parse(Opts, rebar_state:command_args(State1)) of
{ok, Args} ->
- State2 = rebar_state:command_parsed_args(State, Args),
- do(TargetProviders, State2);
+ State3 = rebar_state:command_parsed_args(State1, Args),
+ do(TargetProviders, State3);
{error, {invalid_option, Option}} ->
{error, io_lib:format("Invalid option ~s on task ~p", [Option, Command])}
end
end
end.
--spec do([atom()], rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
+-spec do([{atom(), atom()}], rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
do([], State) ->
{ok, State};
-do([ProviderName | Rest], State) ->
+do([{ProviderName, Profile} | Rest], State) ->
+ State1 = rebar_state:current_profile(State, Profile),
Provider = providers:get_provider(ProviderName
- ,rebar_state:providers(State)),
- case providers:do(Provider, State) of
- {ok, State1} ->
- do(Rest, State1);
+ ,rebar_state:providers(State1)),
+ case providers:do(Provider, State1) of
+ {ok, State2} ->
+ do(Rest, State2);
{error, Error} ->
{error, Error}
end.
update_code_path(State) ->
true = rebar_utils:expand_code_path(),
- BaseDir = rebar_state:get(State, base_dir, ?DEFAULT_BASE_DIR),
- LibDirs = rebar_state:get(State, lib_dirs, ?DEFAULT_LIB_DIRS),
- DepsDir = filename:join(BaseDir, rebar_state:get(State, deps_dir, ?DEFAULT_DEPS_DIR)),
- PluginsDir = filename:join(BaseDir, rebar_state:get(State, plugins_dir, ?DEFAULT_PLUGINS_DIR)),
+ LibDirs = rebar_dir:lib_dirs(State),
+ DepsDir = rebar_dir:deps_dir(State),
+ PluginsDir = rebar_dir:plugins_dir(State),
_UpdatedCodePaths = update_code_path_([DepsDir, PluginsDir | LibDirs]).
@@ -82,7 +84,7 @@ update_code_path(State) ->
%% ===================================================================
update_code_path_(Paths) ->
- LibPaths = expand_lib_dirs(Paths, rebar_utils:get_cwd(), []),
+ LibPaths = expand_lib_dirs(Paths, rebar_dir:get_cwd(), []),
ok = code:add_pathsa(LibPaths),
%% track just the paths we added, so we can remove them without
%% removing other paths added by this dep