diff options
author | lain <lain@soykaf.club> | 2020-08-06 08:27:10 +0000 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-08-06 08:27:10 +0000 |
commit | 4b47d9c5b621c7c0ef4f2e2a010b323bf362895d (patch) | |
tree | 9d59591575e9f2f0e070efc01ead632396159705 /lib/pleroma/utils.ex | |
parent | 7755f49e281e4990db5317b33d6b8e0d12982e0c (diff) | |
parent | 7569f225f1d43c6435eda6b62fd5eff3cd3408e0 (diff) | |
download | pleroma-4b47d9c5b621c7c0ef4f2e2a010b323bf362895d.tar.gz |
Merge branch 'command-available-check' into 'develop'
#1939 Check command availability for exiftool and git
See merge request pleroma/pleroma!2753
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 |