diff --git a/Cargo.toml b/Cargo.toml index 14d9039..c9d4457 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ edition = "2018" build="build.rs" [modulo] -version = "0.1.0" +version = "0.1.1" [dependencies] widestring = "0.4.0" diff --git a/src/ui/modulo/mac.rs b/src/ui/modulo/mac.rs index 1fc150b..e6bd7e9 100644 --- a/src/ui/modulo/mac.rs +++ b/src/ui/modulo/mac.rs @@ -1,10 +1,25 @@ use log::info; +use std::path::PathBuf; use std::os::unix::fs::symlink; const MODULO_APP_BUNDLE_NAME: &str = "Modulo.app"; const MODULO_APP_BUNDLE_PLIST_CONTENT: &'static str = include_str!("../../res/mac/modulo.plist"); pub fn generate_modulo_app_bundle(modulo_path: &str) -> Result { + let modulo_pathbuf = PathBuf::from(modulo_path); + let modulo_path: String = if !modulo_pathbuf.exists() { + // If modulo was taken from the PATH, we need to calculate the absolute path + // To do so, we use the `which` command + let output = std::process::Command::new("which").arg("modulo").output().expect("unable to call 'which' command to determine modulo's full path"); + let path = String::from_utf8_lossy(output.stdout.as_slice()); + let path = path.trim(); + + info!("Detected modulo's full path: {:?}", &path); + path.to_string() + }else{ + modulo_path.to_owned() + }; + let data_dir = crate::context::get_data_dir(); let modulo_app_dir = data_dir.join(MODULO_APP_BUNDLE_NAME); @@ -24,7 +39,7 @@ pub fn generate_modulo_app_bundle(modulo_path: &str) -> Result