mirror of
https://github.com/nushell/nushell.git
synced 2025-05-08 20:14:26 +02:00
Merge e354301538
into a0d7c1a4fd
This commit is contained in:
commit
4fb7972be4
@ -173,6 +173,11 @@ fn read_and_sort_directory(path: &Path) -> Result<Vec<String>> {
|
|||||||
Ok(entries)
|
Ok(entries)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn nu_autoload_on_command(engine_state: &EngineState, stack: &Stack) -> bool {
|
||||||
|
let env_vars = stack.get_env_vars(engine_state);
|
||||||
|
env_vars.contains_key("NU_AUTOLOAD_ON_COMMAND")
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn read_vendor_autoload_files(engine_state: &mut EngineState, stack: &mut Stack) {
|
pub(crate) fn read_vendor_autoload_files(engine_state: &mut EngineState, stack: &mut Stack) {
|
||||||
warn!(
|
warn!(
|
||||||
"read_vendor_autoload_files() {}:{}:{}",
|
"read_vendor_autoload_files() {}:{}:{}",
|
||||||
@ -180,10 +185,20 @@ pub(crate) fn read_vendor_autoload_files(engine_state: &mut EngineState, stack:
|
|||||||
line!(),
|
line!(),
|
||||||
column!()
|
column!()
|
||||||
);
|
);
|
||||||
|
let mut autoload_dirs = get_vendor_autoload_dirs(engine_state);
|
||||||
|
if nu_autoload_on_command(engine_state, stack) {
|
||||||
|
// Check for custom autoload dir in Nushell's environment
|
||||||
|
let env_vars = stack.get_env_vars(engine_state);
|
||||||
|
if let Some(val) = env_vars.get("NU_VENDOR_AUTOLOAD_DIR") {
|
||||||
|
if let Ok(path_str) = val.as_str() {
|
||||||
|
let path = std::path::PathBuf::from(path_str);
|
||||||
|
autoload_dirs.push(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// The evaluation order is first determined by the semantics of `get_vendor_autoload_dirs`
|
// Use our modified autoload_dirs list
|
||||||
// to determine the order of directories to evaluate
|
autoload_dirs // Changed: use our modified list instead of calling get_vendor_autoload_dirs again
|
||||||
get_vendor_autoload_dirs(engine_state)
|
|
||||||
.iter()
|
.iter()
|
||||||
// User autoload directories are evaluated after vendor, which means that
|
// User autoload directories are evaluated after vendor, which means that
|
||||||
// the user can override vendor autoload files
|
// the user can override vendor autoload files
|
||||||
@ -206,6 +221,11 @@ pub(crate) fn read_vendor_autoload_files(engine_state: &mut EngineState, stack:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Add environment merging here to ensure changes take effect
|
||||||
|
if let Err(e) = engine_state.merge_env(stack) {
|
||||||
|
report_shell_error(engine_state, &e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn eval_default_config(
|
fn eval_default_config(
|
||||||
|
11
src/run.rs
11
src/run.rs
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
command,
|
command,
|
||||||
config_files::{self, setup_config},
|
config_files::{self, nu_autoload_on_command, read_vendor_autoload_files, setup_config},
|
||||||
};
|
};
|
||||||
use log::trace;
|
use log::trace;
|
||||||
#[cfg(feature = "plugin")]
|
#[cfg(feature = "plugin")]
|
||||||
@ -76,6 +76,15 @@ pub(crate) fn run_commands(
|
|||||||
}
|
}
|
||||||
|
|
||||||
perf!("read login.nu", start_time, use_color);
|
perf!("read login.nu", start_time, use_color);
|
||||||
|
// Only run vendor autoload if NU_AUTOLOAD_ON_COMMAND is set
|
||||||
|
|
||||||
|
if nu_autoload_on_command(engine_state, &stack) {
|
||||||
|
read_vendor_autoload_files(engine_state, &mut stack);
|
||||||
|
if let Err(e) = engine_state.merge_env(&mut stack) {
|
||||||
|
report_shell_error(engine_state, &e);
|
||||||
|
}
|
||||||
|
perf!("read vendor autoload", start_time, use_color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Before running commands, set up the startup time
|
// Before running commands, set up the startup time
|
||||||
|
Loading…
Reference in New Issue
Block a user