From 9e198a454659ea1ea7510bfc2490e03521128272 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 19 Jun 2024 17:47:41 +0800 Subject: [PATCH] Add convenience func to check if command exists Signed-off-by: Claudio Cambra --- admin/osx/craft-client.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/admin/osx/craft-client.swift b/admin/osx/craft-client.swift index 219bd710a..e5e94f95f 100644 --- a/admin/osx/craft-client.swift +++ b/admin/osx/craft-client.swift @@ -40,3 +40,7 @@ func run( func shell(_ commands: String..., env: [String: String]? = nil, quiet: Bool = false) -> Int32 { return run("/bin/zsh", ["-c"] + commands, env: env, quiet: quiet) } + +func commandExists(_ command: String) -> Bool { + return run("/usr/bin/type", command, quiet: true) == 0 +} -- 2.39.5