From 84f891ea3e31c936bc990a3c2310d539df62fc44 Mon Sep 17 00:00:00 2001
From: Egor Kislitsyn <egor@kislitsyn.com>
Date: Mon, 9 Dec 2019 18:23:07 +0700
Subject: [PATCH] Add Pleroma.Utils.compile_dir/1

---
 lib/pleroma/application.ex |  4 +---
 lib/pleroma/utils.ex       | 12 ++++++++++++
 2 files changed, 13 insertions(+), 3 deletions(-)
 create mode 100644 lib/pleroma/utils.ex

diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex
index 82a005700..104620b37 100644
--- a/lib/pleroma/application.ex
+++ b/lib/pleroma/application.ex
@@ -73,9 +73,7 @@ def load_custom_modules do
 
     if dir && File.exists?(dir) do
       dir
-      |> File.ls!()
-      |> Enum.map(&Path.join(dir, &1))
-      |> Kernel.ParallelCompiler.compile()
+      |> Pleroma.Utils.compile_dir()
       |> case do
         {:error, _errors, _warnings} ->
           raise "Invalid custom modules"
diff --git a/lib/pleroma/utils.ex b/lib/pleroma/utils.ex
new file mode 100644
index 000000000..8d36a0001
--- /dev/null
+++ b/lib/pleroma/utils.ex
@@ -0,0 +1,12 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Utils do
+  def compile_dir(dir) when is_binary(dir) do
+    dir
+    |> File.ls!()
+    |> Enum.map(&Path.join(dir, &1))
+    |> Kernel.ParallelCompiler.compile()
+  end
+end