diff options
Diffstat (limited to 'lib/pleroma/utils.ex')
-rw-r--r-- | lib/pleroma/utils.ex | 14 |
1 files changed, 14 insertions, 0 deletions
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 |