From 3f9871f60d022dbe543a45c083608f31eda8cebd Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Fri, 29 May 2020 07:14:32 +1200 Subject: [PATCH] Simplify plugin directory scanning (#1910) --- crates/nu-cli/src/cli.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/crates/nu-cli/src/cli.rs b/crates/nu-cli/src/cli.rs index 4d6edc670f..decd4fc924 100644 --- a/crates/nu-cli/src/cli.rs +++ b/crates/nu-cli/src/cli.rs @@ -110,13 +110,19 @@ fn search_paths() -> Vec { } } - #[cfg(not(debug_assertions))] - { - match env::var_os("PATH") { - Some(paths) => { - search_paths.extend(env::split_paths(&paths).collect::>()); + if let Ok(config) = crate::data::config::config(Tag::unknown()) { + if let Some(plugin_dirs) = config.get("plugin_dirs") { + if let Value { + value: UntaggedValue::Table(pipelines), + .. + } = plugin_dirs + { + for pipeline in pipelines { + if let Ok(plugin_dir) = pipeline.as_string() { + search_paths.push(PathBuf::from(plugin_dir)); + } + } } - None => println!("PATH is not defined in the environment."), } }