extend custom runtime system
All checks were successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/docs Pipeline was successful
ci/woodpecker/push/release Pipeline was successful
ci/woodpecker/pr/release Pipeline was successful
ci/woodpecker/pr/docs Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
All checks were successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/docs Pipeline was successful
ci/woodpecker/push/release Pipeline was successful
ci/woodpecker/pr/release Pipeline was successful
ci/woodpecker/pr/docs Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
also expose some user stuff for custom authenticators
This commit is contained in:
parent
f9a7b456eb
commit
f73c93e4be
5 changed files with 26 additions and 1 deletions
|
@ -14,10 +14,23 @@ defmodule Pleroma.Utils do
|
|||
@repo_timeout Pleroma.Config.get([Pleroma.Repo, :timeout], 15_000)
|
||||
|
||||
def compile_dir(dir) when is_binary(dir) do
|
||||
dir
|
||||
|> elixir_files()
|
||||
|> Kernel.ParallelCompiler.compile()
|
||||
end
|
||||
|
||||
defp elixir_files(dir) when is_binary(dir) do
|
||||
dir
|
||||
|> File.ls!()
|
||||
|> Enum.map(&Path.join(dir, &1))
|
||||
|> Kernel.ParallelCompiler.compile()
|
||||
|> Enum.flat_map(fn path ->
|
||||
if File.dir?(path) do
|
||||
elixir_files(path)
|
||||
else
|
||||
[path]
|
||||
end
|
||||
end)
|
||||
|> Enum.filter(fn path -> String.ends_with?(path, ".ex") end)
|
||||
end
|
||||
|
||||
@doc """
|
||||
|
|
2
test/fixtures/runtime_modules/first.ex
vendored
Normal file
2
test/fixtures/runtime_modules/first.ex
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
defmodule DynamicModule.First do
|
||||
end
|
1
test/fixtures/runtime_modules/nope.exs
vendored
Normal file
1
test/fixtures/runtime_modules/nope.exs
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
def thisisnotloaded
|
2
test/fixtures/runtime_modules/subdir/second.ex
vendored
Normal file
2
test/fixtures/runtime_modules/subdir/second.ex
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
defmodule DynamicModule.Second do
|
||||
end
|
|
@ -12,4 +12,11 @@ test "returns unique temporary directory" do
|
|||
File.rm_rf(path)
|
||||
end
|
||||
end
|
||||
|
||||
describe "compile_dir/1" do
|
||||
test "recursively compiles directories" do
|
||||
{:ok, [DynamicModule.First, DynamicModule.Second], []} =
|
||||
Pleroma.Utils.compile_dir("test/fixtures/runtime_modules")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue