mirror of
https://github.com/nushell/nushell.git
synced 2024-12-25 08:29:07 +01:00
Include only *.nu
files in the vendor autoload (#13599)
# Description Fixes #13587 # User-Facing Changes Files without ending or non-`*.nu` files will not be loaded as vendor/configuration files. # Tests + Formatting So far we don't have any tests for that..
This commit is contained in:
parent
059167ac96
commit
80c8edcfb4
@ -177,6 +177,9 @@ pub(crate) fn read_default_env_file(engine_state: &mut EngineState, stack: &mut
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get files sorted lexicographically
|
||||||
|
///
|
||||||
|
/// uses `impl Ord for String`
|
||||||
fn read_and_sort_directory(path: &Path) -> Result<Vec<String>> {
|
fn read_and_sort_directory(path: &Path) -> Result<Vec<String>> {
|
||||||
let mut entries = Vec::new();
|
let mut entries = Vec::new();
|
||||||
|
|
||||||
@ -200,13 +203,19 @@ pub(crate) fn read_vendor_autoload_files(engine_state: &mut EngineState, stack:
|
|||||||
column!()
|
column!()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// The evaluation order is first determined by the semantics of `get_vendor_autoload_dirs`
|
||||||
|
// to determine the order of directories to evaluate
|
||||||
for autoload_dir in nu_protocol::eval_const::get_vendor_autoload_dirs(engine_state) {
|
for autoload_dir in nu_protocol::eval_const::get_vendor_autoload_dirs(engine_state) {
|
||||||
warn!("read_vendor_autoload_files: {}", autoload_dir.display());
|
warn!("read_vendor_autoload_files: {}", autoload_dir.display());
|
||||||
|
|
||||||
if autoload_dir.exists() {
|
if autoload_dir.exists() {
|
||||||
|
// on a second levels files are lexicographically sorted by the string of the filename
|
||||||
let entries = read_and_sort_directory(&autoload_dir);
|
let entries = read_and_sort_directory(&autoload_dir);
|
||||||
if let Ok(entries) = entries {
|
if let Ok(entries) = entries {
|
||||||
for entry in entries {
|
for entry in entries {
|
||||||
|
if !entry.ends_with(".nu") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
let path = autoload_dir.join(entry);
|
let path = autoload_dir.join(entry);
|
||||||
warn!("AutoLoading: {:?}", path);
|
warn!("AutoLoading: {:?}", path);
|
||||||
eval_config_contents(path, engine_state, stack);
|
eval_config_contents(path, engine_state, stack);
|
||||||
|
Loading…
Reference in New Issue
Block a user