little refactor

This commit is contained in:
Alex S 2019-09-03 20:06:22 +03:00
parent 5ff12e7df1
commit be32d90a0c

View file

@ -4,11 +4,13 @@ defmodule Pleroma.Docs.JSON do
@spec process(keyword()) :: {:ok, String.t()} @spec process(keyword()) :: {:ok, String.t()}
def process(descriptions) do def process(descriptions) do
config_path = "docs/generate_config.json" config_path = "docs/generate_config.json"
{:ok, file} = File.open(config_path, [:write])
json = generate_json(descriptions) with {:ok, file} <- File.open(config_path, [:write]),
IO.write(file, json) json <- generate_json(descriptions),
:ok = File.close(file) :ok <- IO.write(file, json),
{:ok, config_path} :ok <- File.close(file) do
{:ok, config_path}
end
end end
@spec generate_json([keyword()]) :: String.t() @spec generate_json([keyword()]) :: String.t()