From 055e8c0b9d962e73dcb415af769ccc9523d43ab4 Mon Sep 17 00:00:00 2001 From: Luis Rascao Date: Sun, 7 Feb 2016 01:07:26 +0000 Subject: [PATCH] Remove restriction for mandatory presence of vm.args fields in schema If none are present then don't bother generating the vm.args file at all. --- src/cuttlefish_escript.erl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/cuttlefish_escript.erl b/src/cuttlefish_escript.erl index 81c932c6..e9b5b211 100644 --- a/src/cuttlefish_escript.erl +++ b/src/cuttlefish_escript.erl @@ -391,15 +391,21 @@ engage_cuttlefish(ParsedArgs) -> error; _ -> FinalAppConfig = proplists:delete(vm_args, FinalConfig), - FinalVMArgs = cuttlefish_vmargs:stringify(proplists:get_value(vm_args, FinalConfig)), + FinalVMArgs = cuttlefish_vmargs:stringify(proplists:get_value(vm_args, FinalConfig, [])), %% Prune excess files MaxHistory = proplists:get_value(max_history, ParsedArgs, 3) - 1, prune(Destination, MaxHistory), prune(DestinationVMArgs, MaxHistory), - case { file:write_file(Destination, io_lib:fwrite("~p.\n",[FinalAppConfig])), - file:write_file(DestinationVMArgs, string:join(FinalVMArgs, "\n"))} of + AppConfigWriteResult = file:write_file(Destination, io_lib:fwrite("~p.\n",[FinalAppConfig])), + %% don't bother writing vm.args if theres nothing to write + VMArgsWriteResult = case FinalVMArgs of + "" -> ok; + _ -> file:write_file(DestinationVMArgs, string:join(FinalVMArgs, "\n")) + end, + + case {AppConfigWriteResult, VMArgsWriteResult} of {ok, ok} -> {Destination, DestinationVMArgs}; {Err1, Err2} ->