mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-23 00:58:32 +02:00
cli: prefer cwd plugins dir when present
This commit is contained in:
@@ -135,35 +135,16 @@ fn prepare_embedded_vendored_plugins(vendored_plugin_dir: &Path) -> std::io::Res
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_workspace_plugins_dir() -> Option<PathBuf> {
|
fn resolve_bundled_plugin_dir_for_cli(embedded_vendored_plugin_dir: &Path) -> PathBuf {
|
||||||
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
resolve_workspace_plugins_dir_from_cwd()
|
||||||
.join("../..")
|
.unwrap_or_else(|| embedded_vendored_plugin_dir.to_path_buf())
|
||||||
.join("plugins")
|
|
||||||
.canonicalize()
|
|
||||||
.ok()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_bundled_plugin_dir_for_cli(embedded_vendored_plugin_dir: &Path) -> PathBuf {
|
fn resolve_workspace_plugins_dir_from_cwd() -> Option<PathBuf> {
|
||||||
if !use_workspace_plugins_for_cli_dev() {
|
let plugins_dir = std::env::current_dir().ok()?.join("plugins");
|
||||||
return embedded_vendored_plugin_dir.to_path_buf();
|
if !plugins_dir.is_dir() {
|
||||||
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve_workspace_plugins_dir().unwrap_or_else(|| {
|
plugins_dir.canonicalize().ok().or(Some(plugins_dir))
|
||||||
panic!(
|
|
||||||
"YAAK_USE_WORKSPACE_PLUGINS is enabled, but ROOT/plugins could not be resolved"
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn use_workspace_plugins_for_cli_dev() -> bool {
|
|
||||||
std::env::var("YAAK_USE_WORKSPACE_PLUGINS")
|
|
||||||
.ok()
|
|
||||||
.map(|v| {
|
|
||||||
let v = v.trim();
|
|
||||||
v.eq_ignore_ascii_case("1")
|
|
||||||
|| v.eq_ignore_ascii_case("true")
|
|
||||||
|| v.eq_ignore_ascii_case("yes")
|
|
||||||
|| v.eq_ignore_ascii_case("on")
|
|
||||||
})
|
|
||||||
.unwrap_or(false)
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user