-
Notifications
You must be signed in to change notification settings - Fork 189
Open
Description
With the .autoload file you can give a custom load order to files.
However, this works only for .jl files, and not for recursive folder structures, meaning I cannot change the order that i.e. my Modules are loaded in.
For the most part, this is not a problem; however sometimes it is meaningful to load files from different folders in a set order. Furthermore, I find this behavior inconsistent and confusing.
For that Reason I propose to change the function autoload into a truly recursive implementation, handling hierachic .autoload files.
function autoload(root_dir::String = Genie.config.path_lib;
context::Union{Module,Nothing} = nothing,
skipdirs::Vector{String} = String[],
namematch::Regex = r".*",
skipmatch::Union{Regex,Nothing} = nothing,
autoload_ignore_file::String = Genie.config.autoload_ignore_file,
autoload_file::String = Genie.config.autoload_file) :: Nothing
isdir(root_dir) || return nothing
validinclude(fi)::Bool = endswith(fi, ".jl") && match(namematch, fi) !== nothing &&
((skipmatch !== nothing && match(skipmatch, fi) === nothing) || skipmatch === nothing)
for i in sort_load_order(root_dir, readdir(root_dir))
(isfile(joinpath(root_dir, autoload_ignore_file)) || i == autoload_file ) && continue
fi = joinpath(root_dir, i)
@debug "Checking $fi"
if validinclude(fi)
@debug "Auto loading file: $fi"
Revise.includet(default_context(context), fi)
elseif isdir(fi)
i ∈ skipdirs && continue
autoload(fi; context=context,
skipdirs=skipdirs,
namematch=namematch,
skipmatch=skipmatch,
autoload_ignore_file=autoload_ignore_file,
autoload_file=autoload_file)
end
end
nothing
endHere, I replaced the walkdir part of the code with a recursive call on the sub directories.
Metadata
Metadata
Assignees
Labels
No labels