diff options
author | rinpatch <rinpatch@sdf.org> | 2019-06-08 17:40:40 +0300 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2019-06-08 17:40:40 +0300 |
commit | d7ec0898e5aa7acae463760fd85d1ebf8307b4f9 (patch) | |
tree | 35a30d91ca93ce74909b707f8b5a38e166c2d94b /lib/pleroma | |
parent | 4b98a7ce4ef4b4e7b74f533e6d6ed343e1b34c48 (diff) | |
download | pleroma-d7ec0898e5aa7acae463760fd85d1ebf8307b4f9.tar.gz |
Make mix tasks work in a release
Diffstat (limited to 'lib/pleroma')
-rw-r--r-- | lib/pleroma/release_tasks.ex | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/pleroma/release_tasks.ex b/lib/pleroma/release_tasks.ex new file mode 100644 index 000000000..66a8b627f --- /dev/null +++ b/lib/pleroma/release_tasks.ex @@ -0,0 +1,38 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/> +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Pleroma.ReleaseTasks do + def run(args) do + [task | args] = String.split(args) + + case task do + "migrate" -> migrate(args) + task -> mix_task(task, args) + end + end + + defp mix_task(task, args) do + # Modules are not loaded before application starts + Mix.Tasks.Pleroma.Common.start_pleroma() + {:ok, modules} = :application.get_key(:pleroma, :modules) + + module = + Enum.find(modules, fn module -> + module = Module.split(module) + + match?(["Mix", "Tasks", "Pleroma" | _], module) and + String.downcase(List.last(module)) == task + end) + + if module do + module.run(args) + else + IO.puts("The task #{task} does not exist") + end + end + + defp migrate(_args) do + :noop + end +end |