diff options
author | Dave Smith <dizzyd@dizzyd.com> | 2009-12-10 12:16:15 -0700 |
---|---|---|
committer | Dave Smith <dizzyd@dizzyd.com> | 2009-12-10 12:16:15 -0700 |
commit | 849078026e50816f6303e3a73fff1dd8c0206896 (patch) | |
tree | b1a08e9d8da30f7923437fd9ccfc8bd54a74d954 | |
parent | b088139ed09c16816155eb79560b64878ebc2ab6 (diff) |
Add ability to forcibly overwrite existing release
-rw-r--r-- | src/rebar_reltool.erl | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/rebar_reltool.erl b/src/rebar_reltool.erl index d228202..e1ffbe0 100644 --- a/src/rebar_reltool.erl +++ b/src/rebar_reltool.erl @@ -137,7 +137,20 @@ run_reltool(Config, ReltoolConfig) -> {ok, Spec} -> dump_spec(Spec), TargetDir = target_dir(Config, ReltoolConfig), - ok = file:make_dir(TargetDir), + case file:make_dir(TargetDir) of + ok -> + ok; + {error, eexist} -> + %% Output directory already exists; if force=1, wipe it out + case rebar_config:get_global(force, "0") of + "1" -> + rebar_file_utils:rm_rf(TargetDir), + ok = file:make_dir(TargetDir); + _ -> + ?ERROR("Release target directory ~p already exists!\n", [TargetDir]), + ?FAIL + end + end, case reltool:eval_target_spec(Spec, code:root_dir(), TargetDir) of ok -> ok; |