Skip to content

src_watch

WooKyoung Noh edited this page Jan 9, 2019 · 1 revision
using Jive
using Revise
using Example

using FileWatching # FolderMonitor
function src_watch(cb, modul)
    src_dir = dirname(pathof(modul))
    target_dirs = [root for (root, dirs, files) in walkdir(src_dir)]
    @info :target_dirs target_dirs
    loops = []
    for dir in target_dirs
        loop = Task() do
            fm = FolderMonitor(dir)
            while fm.open
                (fname, events) = wait(fm)::Pair
                endswith(fname, ".jl") && cb(relpath(dir, src_dir), fname)
            end
        end
        push!(loops, loop)
    end
    schedule.(loops)
end

src_watch(Example) do dir, fname
    @info (dir, fname)
    Jive.run(dir, fname)
end
Clone this wiki locally