From 849078026e50816f6303e3a73fff1dd8c0206896 Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Thu, 10 Dec 2009 12:16:15 -0700 Subject: [PATCH] Add ability to forcibly overwrite existing release --- src/rebar_reltool.erl | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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;