diff --git a/Project.toml b/Project.toml index 38ca7b9b5..2fc995895 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Genie" uuid = "c43c736e-a2d1-11e8-161f-af95117fbd1e" authors = ["Adrian Salceanu and the amazing Genie contributors ♥️"] -version = "5.30.2" +version = "5.30.3" [deps] ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63" diff --git a/src/Util.jl b/src/Util.jl index 5652379ba..24694a07e 100755 --- a/src/Util.jl +++ b/src/Util.jl @@ -20,7 +20,9 @@ end Recursively walks dir and `produce`s non directories. If `only_files`, directories will be skipped. If `only_dirs`, files will be skipped. """ function walk_dir(dir, paths = String[]; - only_extensions = ["jl"], only_files = true, only_dirs = false, + only_extensions = ["jl"], + only_files = true, + only_dirs = false, exceptions = Genie.config.watch_exceptions, autoload_ignorefile = Genie.config.autoload_ignore_file) :: Vector{String} f = readdir(dir) diff --git a/src/Watch.jl b/src/Watch.jl index 260a205a4..ee559a4f0 100644 --- a/src/Watch.jl +++ b/src/Watch.jl @@ -22,6 +22,7 @@ end function watchpath(path::Union{S,Vector{S}}) where {S<:AbstractString} isa(path, Vector) || (path = String[path]) push!(WATCHED_FOLDERS[], path...) + unique!(WATCHED_FOLDERS[]) end function delete_handlers(key::Any) @@ -31,6 +32,7 @@ end function add_handler!(key::S, handler::F) where {F<:Function, S<:AbstractString} haskey(WATCH_HANDLERS[], key) || (WATCH_HANDLERS[][key] = Function[]) push!(WATCH_HANDLERS[][key], handler) + unique!(WATCH_HANDLERS[][key]) end function handlers!(key::S, handlers::Vector{<: Function}) where {S<:AbstractString} @@ -41,24 +43,26 @@ function handlers() :: Vector{<: Function} WATCH_HANDLERS[] |> values |> collect |> Iterators.flatten |> collect end -function watch(files::Vector{<: AbstractString}, extensions::Vector{<: AbstractString} = Genie.config.watch_extensions; handlers::Vector{<: Function} = handlers()) :: Nothing +function watch(files::Vector{<: AbstractString}, + extensions::Vector{<: AbstractString} = Genie.config.watch_extensions; + handlers::Vector{<: Function} = handlers()) :: Nothing last_watched = now() - Millisecond(Genie.config.watch_frequency) # to trigger the first watch Genie.Configuration.isdev() && Revise.revise() - if ! (hash(handlers) in WATCHING[]) - push!(WATCHING[], hash(handlers)) - else - @warn "Handlers already registered" - return - end + # if ! (hash(handlers) in WATCHING[]) + # push!(WATCHING[], hash(handlers)) + # else + # Genie.Configuration.isdev() && @warn("Handlers already registered") + # return + # end entr(collect_watched_files(WATCHED_FOLDERS[], extensions); all = true) do now() - last_watched > Millisecond(Genie.config.watch_frequency) || return last_watched = now() try - for f in handlers + for f in unique!(handlers) Base.invokelatest(f) end catch ex