Merge branch 'optimize-command_available' into 'develop'

Optimize Pleroma.Utils.command_available?/1

See merge request pleroma/pleroma!3254
This commit is contained in:
Haelwenn 2021-01-15 04:44:58 +00:00
commit cf367fdbd5

View File

@ -30,7 +30,10 @@ defmodule Pleroma.Utils do
"""
@spec command_available?(String.t()) :: boolean()
def command_available?(command) do
match?({_output, 0}, System.cmd("sh", ["-c", "command -v #{command}"]))
case :os.find_executable(String.to_charlist(command)) do
false -> false
_ -> true
end
end
@doc "creates the uniq temporary directory"