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
1 changed files with 4 additions and 1 deletions

View File

@ -30,7 +30,10 @@ def compile_dir(dir) when is_binary(dir) do
""" """
@spec command_available?(String.t()) :: boolean() @spec command_available?(String.t()) :: boolean()
def command_available?(command) do 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 end
@doc "creates the uniq temporary directory" @doc "creates the uniq temporary directory"