From 8a6ce79c6f6794912bb375adaaeded2b7b6bf4fe Mon Sep 17 00:00:00 2001 From: Nigel Ihza Firdausy <106657905+Ni-zav@users.noreply.github.com> Date: Tue, 13 Oct 2026 11:02:03 +0700 Subject: [PATCH] fix(macos): bundle the CLI and resolve it from generated droplets --- crates/engine/src/automate_cmds.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/automate_cmds.rs b/crates/engine/src/automate_cmds.rs index 6a98ee3c4f..9b75a1842e 100644 --- a/crates/engine/src/automate_cmds.rs +++ b/crates/engine/src/automate_cmds.rs @@ -328,9 +328,20 @@ fn write_shim(droplet: &str) -> Result { // quoted segment, emit a literal quote, then resume it. let quoted_abs = format!("'{}'", abs.replace('\'', "'\\''")); let body = format!( - "#!/bin/sh\n# PhotoCraft droplet: runs the action on the files given (or dropped).\nexec \"${{PHOTOCRAFT_CLI:-photocraft-cli}}\" droplet {quoted_abs} \"$@\"\n" - ); - crate::file_cmds::write_file(&shim, body.as_bytes())?; + r#"#!/bin/sh +# PhotoCraft droplet: runs the action on the files given (or dropped). +if [ -n "${{PHOTOCRAFT_CLI:-}}" ]; then + cli="$PHOTOCRAFT_CLI" +elif [ -x /Applications/PhotoCraft.app/Contents/MacOS/photocraft-cli ]; then + cli=/Applications/PhotoCraft.app/Contents/MacOS/photocraft-cli +elif [ -x "$HOME/Applications/PhotoCraft.app/Contents/MacOS/photocraft-cli" ]; then + cli="$HOME/Applications/PhotoCraft.app/Contents/MacOS/photocraft-cli" +else + cli=photocraft-cli +fi +exec "$cli" droplet {quoted_abs} "$@" +"# + ); crate::file_cmds::write_file(&shim, body.as_bytes())?; #[cfg(unix)] { use std::os::unix::fs::PermissionsExt;