summaryrefslogtreecommitdiff
path: root/src/rebar_state.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/rebar_state.erl')
-rw-r--r--src/rebar_state.erl26
1 files changed, 10 insertions, 16 deletions
diff --git a/src/rebar_state.erl b/src/rebar_state.erl
index 213eb2f..f365293 100644
--- a/src/rebar_state.erl
+++ b/src/rebar_state.erl
@@ -78,11 +78,7 @@ new() ->
-spec new(list()) -> t().
new(Config) when is_list(Config) ->
BaseState = base_state(),
- Deps = proplists:get_value(deps, Config, []),
- Plugins = proplists:get_value(plugins, Config, []),
- Terms = [{{deps, default}, Deps}, {{plugins, default}, Plugins} | Config],
- true = rebar_config:verify_config_format(Terms),
- Opts = dict:from_list(Terms),
+ Opts = base_opts(Config),
BaseState#state_t { dir = rebar_dir:get_cwd(),
default = Opts,
opts = Opts }.
@@ -91,12 +87,7 @@ new(Config) when is_list(Config) ->
new(Profile, Config) when is_atom(Profile)
, is_list(Config) ->
BaseState = base_state(),
- Deps = proplists:get_value(deps, Config, []),
-
- Plugins = proplists:get_value(plugins, Config, []),
- Terms = [{{deps, default}, Deps}, {{plugins, default}, Plugins} | Config],
- true = rebar_config:verify_config_format(Terms),
- Opts = dict:from_list(Terms),
+ Opts = base_opts(Config),
BaseState#state_t { dir = rebar_dir:get_cwd(),
current_profiles = [Profile],
default = Opts,
@@ -119,11 +110,7 @@ new(ParentState, Config, Dir) ->
true = rebar_config:verify_config_format(Terms),
dict:from_list(Terms);
_ ->
- D = proplists:get_value(deps, Config, []),
- Plugins = proplists:get_value(plugins, Config, []),
- Terms = [{{deps, default}, D}, {{plugins, default}, Plugins} | Config],
- true = rebar_config:verify_config_format(Terms),
- dict:from_list(Terms)
+ base_opts(Config)
end,
NewOpts = merge_opts(LocalOpts, Opts),
@@ -141,6 +128,13 @@ base_state() ->
end,
#state_t{resources=Resources}.
+base_opts(Config) ->
+ Deps = proplists:get_value(deps, Config, []),
+ Plugins = proplists:get_value(plugins, Config, []),
+ Terms = [{{deps, default}, Deps}, {{plugins, default}, Plugins} | Config],
+ true = rebar_config:verify_config_format(Terms),
+ dict:from_list(Terms).
+
get(State, Key) ->
{ok, Value} = dict:find(Key, State#state_t.opts),
Value.