feat(config): save override config in hocon pretty-print format

This commit is contained in:
Zaiming Shi 2021-09-19 14:33:43 +02:00
parent 6edc9f4221
commit 2edd3879b8
2 changed files with 3 additions and 3 deletions

View File

@ -355,7 +355,7 @@ save_to_override_conf(RawConf) ->
undefined -> ok; undefined -> ok;
FileName -> FileName ->
ok = filelib:ensure_dir(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; ok -> ok;
{error, Reason} -> {error, Reason} ->
logger:error("write to ~s failed, ~p", [FileName, 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)]. [Name || Name <- get_root_names(), lists:member(Name, Keys)].
atom(Bin) when is_binary(Bin) -> atom(Bin) when is_binary(Bin) ->
binary_to_existing_atom(Bin, latin1); binary_to_existing_atom(Bin, utf8);
atom(Str) when is_list(Str) -> atom(Str) when is_list(Str) ->
list_to_existing_atom(Str); list_to_existing_atom(Str);
atom(Atom) when is_atom(Atom) -> 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) -> safe_atom(Str) when is_list(Str) ->
list_to_existing_atom(Str); list_to_existing_atom(Str);
safe_atom(Atom) when is_atom(Atom) -> safe_atom(Atom) when is_atom(Atom) ->
Atom. Atom.