Merge pull request #5775 from zmstone/feat-save-override-config-in-pp-hocon-format

feat(config): save override config in hocon pretty-print format
This commit is contained in:
Zaiming (Stone) Shi 2021-09-21 22:07:51 +02:00 committed by GitHub
commit f0e58d0c9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -355,7 +355,7 @@ save_to_override_conf(RawConf) ->
undefined -> ok;
FileName ->
ok = filelib:ensure_dir(FileName),
case file:write_file(FileName, jsx:prettify(jsx:encode(RawConf))) of
case file:write_file(FileName, hocon_pp:do(RawConf, #{})) of
ok -> ok;
{error, Reason} ->
logger:error("write to ~s failed, ~p", [FileName, Reason]),
@ -424,7 +424,7 @@ root_names_from_conf(RawConf) ->
[Name || Name <- get_root_names(), lists:member(Name, Keys)].
atom(Bin) when is_binary(Bin) ->
binary_to_existing_atom(Bin, latin1);
binary_to_existing_atom(Bin, utf8);
atom(Str) when is_list(Str) ->
list_to_existing_atom(Str);
atom(Atom) when is_atom(Atom) ->

View File

@ -310,4 +310,4 @@ safe_atom(Bin) when is_binary(Bin) ->
safe_atom(Str) when is_list(Str) ->
list_to_existing_atom(Str);
safe_atom(Atom) when is_atom(Atom) ->
Atom.
Atom.