brew
change ouwszutqlrqxnqwvrovztqxtmvzlxmom
commit 33e3dbd372412698c9c10663db2c1e33b27e5949
author Alpha Chen <alpha@kejadlen.dev>
date
parent yrqmlzzv
diff --git a/frork-cli/src/assertions.rs b/frork-cli/src/assertions.rs
index d0462bc..9fce112 100644
--- a/frork-cli/src/assertions.rs
+++ b/frork-cli/src/assertions.rs
@@ -485,6 +485,11 @@ impl std::fmt::Display for Brew {
 
 impl AssertionType for Brew {
     fn status(&self) -> Result<Status> {
+        // Early return if brew command is not in PATH
+        if Utils::assert_bin("brew").is_err() {
+            return Ok(Status::Missing);
+        }
+
         let (_output, exit_code) = Utils::sh("brew", &["--version".to_string()])?;
         if exit_code == 0 {
             Ok(Status::Ok)
diff --git a/frork-cli/src/main.rs b/frork-cli/src/main.rs
index b28a13b..940caed 100644
--- a/frork-cli/src/main.rs
+++ b/frork-cli/src/main.rs
@@ -3,8 +3,8 @@ mod errors;
 mod utils;
 
 use assertions::{
-    AssertionType, AssertionTypeFactory, Brew, BrewBundle, Debug, Directory, Git, LuaAssertion, LuaAssertionType,
-    Status, Symlink, TypedFactory,
+    AssertionType, AssertionTypeFactory, Brew, BrewBundle, Debug, Directory, Git, LuaAssertion,
+    LuaAssertionType, Status, Symlink, TypedFactory,
 };
 use clap::{Parser, Subcommand};
 use color_eyre::{Result, eyre::eyre};
diff --git a/frork-cli/src/utils.rs b/frork-cli/src/utils.rs
index 79659a8..558f8f6 100644
--- a/frork-cli/src/utils.rs
+++ b/frork-cli/src/utils.rs
@@ -148,8 +148,15 @@ impl Utils {
         Self::sh_with_envs(cmd, args, &[])
     }
 
-    pub fn sh_with_envs(cmd: &str, args: &[String], env_vars: &[(&str, &str)]) -> Result<(String, i32)> {
-        debug!("Executing command: {} with args: {:?} and envs: {:?}", cmd, args, env_vars);
+    pub fn sh_with_envs(
+        cmd: &str,
+        args: &[String],
+        env_vars: &[(&str, &str)],
+    ) -> Result<(String, i32)> {
+        debug!(
+            "Executing command: {} with args: {:?} and envs: {:?}",
+            cmd, args, env_vars
+        );
 
         let mut command = Command::new(cmd);
         command.args(args);