diff options
Diffstat (limited to 'lib/pleroma')
-rw-r--r-- | lib/pleroma/frontend.ex | 6 | ||||
-rw-r--r-- | lib/pleroma/utils.ex | 14 |
2 files changed, 17 insertions, 3 deletions
diff --git a/lib/pleroma/frontend.ex b/lib/pleroma/frontend.ex index 941e2cfe9..0db697996 100644 --- a/lib/pleroma/frontend.ex +++ b/lib/pleroma/frontend.ex @@ -31,12 +31,12 @@ defmodule Pleroma.Frontend do end @doc """ - Returns path to index.html file for the frontend from the given config. + Returns path to the requested file for the frontend from the given config. If config is not provided, config for the `:primary` frontend is fetched and used. - If index.html file is not found for the requested frontend, the function fallback + If the requested file is not found for the frontend, the function fallback to looking the file at instance static directory and then, in case of failure, in priv/static directory. - Path returned in case of success is guaranteed to be existing file. + Path returned in case of success is guaranteed to be of existing file. """ @spec fe_file_path(String.t(), map()) :: {:ok, String.t()} | {:error, String.t()} def fe_file_path(filename, config \\ nil) do diff --git a/lib/pleroma/utils.ex b/lib/pleroma/utils.ex index 21d1159be..fef9b6cc8 100644 --- a/lib/pleroma/utils.ex +++ b/lib/pleroma/utils.ex @@ -24,4 +24,18 @@ defmodule Pleroma.Utils do def command_available?(command) do match?({_output, 0}, System.cmd("sh", ["-c", "command -v #{command}"])) end + + @doc """ + Throws an exception in case required command is not available + """ + @spec command_required!(String.t()) :: :ok | no_return() + def command_required!(command) do + case command_available?(command) do + true -> + :ok + + false -> + raise "Command #{command} is required, but not available in $PATH" + end + end end |