diff --git a/lua-api-crates/plugin/src/lib.rs b/lua-api-crates/plugin/src/lib.rs index 0eb7be47bef..7676537cd4e 100644 --- a/lua-api-crates/plugin/src/lib.rs +++ b/lua-api-crates/plugin/src/lib.rs @@ -12,6 +12,7 @@ use wezterm_dynamic::{FromDynamic, ToDynamic}; struct RepoSpec { url: String, component: String, + plugin_dir: PathBuf, } /// Given a URL, generate a string that can be used as a directory name. @@ -55,7 +56,13 @@ impl RepoSpec { anyhow::bail!("invalid repo spec {url}"); } - Ok(Self { url, component }) + let plugin_dir = RepoSpec::plugins_dir().join(&component); + + Ok(Self { + url, + component, + plugin_dir, + }) } fn load_from_dir(path: PathBuf) -> anyhow::Result { @@ -66,12 +73,18 @@ impl RepoSpec { .ok_or_else(|| anyhow!("{path:?} isn't unicode"))? .to_string(); + let plugin_dir = RepoSpec::plugins_dir().join(&component); + let repo = Repository::open(&path)?; let remote = get_remote(&repo)?.ok_or_else(|| anyhow!("no remotes!?"))?; let url = remote.url(); if let Some(url) = url { let url = url.to_string(); - return Ok(Self { component, url }); + return Ok(Self { + component, + url, + plugin_dir, + }); } anyhow::bail!("Unable to create a complete RepoSpec for repo at {path:?}"); }