From 06061fbdd031d0214528f28df584296a65d3b480 Mon Sep 17 00:00:00 2001 From: Luis Rascao Date: Sun, 7 Feb 2016 22:45:15 +0000 Subject: [PATCH] Support optional app.config generation without date suffix Depending on wether the dest_file parameter is a complete filename with extension, skip or append the datetime suffix at the end of it. --- src/cuttlefish_escript.erl | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/cuttlefish_escript.erl b/src/cuttlefish_escript.erl index 81c932c6..42a7b0a6 100644 --- a/src/cuttlefish_escript.erl +++ b/src/cuttlefish_escript.erl @@ -346,12 +346,10 @@ engage_cuttlefish(ParsedArgs) -> Path -> Path end, - Date = calendar:local_time(), - - DestinationFilename = filename_maker(proplists:get_value(dest_file, ParsedArgs), Date, "config"), + DestinationFilename = filename_maker(proplists:get_value(dest_file, ParsedArgs), "config"), Destination = filename:join(AbsPath, DestinationFilename), - DestinationVMArgsFilename = filename_maker("vm", Date, "args"), + DestinationVMArgsFilename = filename_maker("vm", "args"), DestinationVMArgs = filename:join(AbsPath, DestinationVMArgsFilename), lager:debug("Generating config in: ~p", [Destination]), @@ -455,8 +453,15 @@ check_existence(EtcDir, Filename) -> lager:info("Checking ~s exists... ~p", [FullName, Exists]), {Exists, FullName}. -filename_maker(Filename, Date, Extension) -> - {{Y, M, D}, {HH, MM, SS}} = Date, +filename_maker(Filename, Extension) -> + case length(string:tokens(Filename, ".")) of + 1 -> filename_maker(add_suffix, Filename, Extension); + _ -> filename_maker(no_suffix, Filename, Extension) + end. + +filename_maker(no_suffix, Filename, _Extension) -> Filename; +filename_maker(add_suffix, Filename, Extension) -> + {{Y, M, D}, {HH, MM, SS}} = calendar:local_time(), _DestinationFilename = io_lib:format("~s.~p.~s.~s.~s.~s.~s.~s", [Filename,