little refactor
authorAlex S <alex.strizhakov@gmail.com>
Tue, 3 Sep 2019 17:06:22 +0000 (20:06 +0300)
committerAlex S <alex.strizhakov@gmail.com>
Wed, 11 Sep 2019 06:25:33 +0000 (09:25 +0300)
lib/pleroma/docs/json.ex

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