diff options
author | Maksim Pechnikov <parallel588@gmail.com> | 2020-08-07 09:48:34 +0300 |
---|---|---|
committer | Maksim Pechnikov <parallel588@gmail.com> | 2020-08-07 09:48:34 +0300 |
commit | 8e90cc58e7ec3f19f03d049ff541750f1ab4774e (patch) | |
tree | be0a4346827a52fcdfe034c489ede989320a24d2 /lib/pleroma/utils.ex | |
parent | 6e6276b4f8a7a46c6038480f6a842339c5214d1c (diff) | |
parent | b9ebb55d2aabdf4c99b05efab9d4ad31b25f888d (diff) | |
download | pleroma-8e90cc58e7ec3f19f03d049ff541750f1ab4774e.tar.gz |
Merge branch 'develop' into feature/update-welcome-setting-in-description
Diffstat (limited to 'lib/pleroma/utils.ex')
-rw-r--r-- | lib/pleroma/utils.ex | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/pleroma/utils.ex b/lib/pleroma/utils.ex index 6b8e3accf..21d1159be 100644 --- a/lib/pleroma/utils.ex +++ b/lib/pleroma/utils.ex @@ -9,4 +9,19 @@ defmodule Pleroma.Utils do |> Enum.map(&Path.join(dir, &1)) |> Kernel.ParallelCompiler.compile() end + + @doc """ + POSIX-compliant check if command is available in the system + + ## Examples + iex> command_available?("git") + true + iex> command_available?("wrongcmd") + false + + """ + @spec command_available?(String.t()) :: boolean() + def command_available?(command) do + match?({_output, 0}, System.cmd("sh", ["-c", "command -v #{command}"])) + end end |