summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2015-08-23 05:48:52 +1200
committerFred Hebert <mononcqc@ferd.ca>2015-08-23 05:48:52 +1200
commit8c826fa92ac2f6f5ebeae92294c367ddc74650d9 (patch)
tree1d5ac02822ea64c5de1c5457e4834aeb85067fc7
parent1f6516b231260a1b2e48f9b86e37a5d317d4983c (diff)
parent86e4c5d5ef39ce9c1ff2c7f9f30e5ab036108f11 (diff)
Merge pull request #735 from tsloughter/relx_output_dir
do not override user cli supplied outputdir for relx
-rw-r--r--src/rebar_relx.erl11
-rw-r--r--test/rebar_release_SUITE.erl33
2 files changed, 36 insertions, 8 deletions
diff --git a/src/rebar_relx.erl b/src/rebar_relx.erl
index a3adedd..699c780 100644
--- a/src/rebar_relx.erl
+++ b/src/rebar_relx.erl
@@ -28,14 +28,12 @@ do(Module, Command, Provider, State) ->
case rebar_state:get(State, relx, []) of
[] ->
relx:main([{lib_dirs, LibDirs}
- ,{output_dir, OutputDir}
- ,{caller, api}], AllOptions);
+ ,{caller, api} | output_dir(OutputDir, Options)], AllOptions);
Config ->
Config1 = update_config(Config),
relx:main([{lib_dirs, LibDirs}
,{config, Config1}
- ,{output_dir, OutputDir}
- ,{caller, api}], AllOptions)
+ ,{caller, api} | output_dir(OutputDir, Options)], AllOptions)
end,
rebar_hooks:run_all_hooks(Cwd, post, Provider, Providers, State),
{ok, State}
@@ -67,3 +65,8 @@ update_config(Config) ->
end
end, {[], []}, Config),
lists:reverse(Special) ++ Other.
+
+%% Don't override output_dir if the user passed one on the command line
+output_dir(OutputDir, Options) ->
+ [{output_dir, OutputDir} || not(lists:member("-o", Options))
+ andalso not(lists:member("--output-dir", Options))].
diff --git a/test/rebar_release_SUITE.erl b/test/rebar_release_SUITE.erl
index 1ef0771..f6fe8ff 100644
--- a/test/rebar_release_SUITE.erl
+++ b/test/rebar_release_SUITE.erl
@@ -4,10 +4,11 @@
-include_lib("eunit/include/eunit.hrl").
all() -> [release,
- dev_mode_release,
- profile_dev_mode_override_release,
- tar,
- extend_release].
+ dev_mode_release,
+ profile_dev_mode_override_release,
+ tar,
+ extend_release,
+ user_output_dir].
init_per_testcase(Case, Config0) ->
Config = rebar_test_utils:init_rebar_state(Config0),
@@ -109,3 +110,27 @@ extend_release(Config) ->
["release", "-n", "extended"],
{ok, [{release, extended, Vsn, false}]}
).
+
+user_output_dir(Config) ->
+ AppDir = ?config(apps, Config),
+ Name = ?config(name, Config),
+ ReleaseDir = filename:join(AppDir, "./_rel"),
+ Vsn = "1.0.0",
+
+ {ok, RebarConfig} =
+ file:consult(rebar_test_utils:create_config(AppDir,
+ [{relx, [{release, {list_to_atom(Name), Vsn},
+ [list_to_atom(Name)]},
+ {lib_dirs, [AppDir]},
+ {dev_mode, true}]}])),
+ rebar_test_utils:run_and_check(
+ Config, RebarConfig,
+ ["release", "-o", ReleaseDir],
+ {ok, []}
+ ),
+
+ RelxState = rlx_state:new("", [], []),
+ RelxState1 = rlx_state:base_output_dir(RelxState, ReleaseDir),
+ {ok, RelxState2} = rlx_prv_app_discover:do(RelxState1),
+ {ok, RelxState3} = rlx_prv_rel_discover:do(RelxState2),
+ rlx_state:get_realized_release(RelxState3, list_to_atom(Name), Vsn).