JuliaPluto / BetterFileWatching.jl

FileWatching but based on Deno.watchFs
MIT License
14 stars 0 forks source link

BetterFileWatching.jl

watch_folder(f::Function, dir=".")

Watch a folder recursively for any changes. Includes changes to file contents. A FileEvent is passed to the callback function f.

watch_file(f::Function, filename=".")

Watch a file for changes. A FileEvent is passed to the callback function f.

Example

watch_folder(".") do event
    @info "Something changed!" event
end

You can watch a folder asynchronously, and interrupt the task later:

watch_task = @async watch_folder(".") do event
    @info "Something changed!" event
end

sleep(5)

# stop watching the folder
schedule(watch_task, InterruptException(); error=true)

Differences with the FileWatching stdlib

BetterFileWatching.watch_file is an alternative to FileWatching.watch_file. The differences are:

BetterFileWatching.watch_folder is an alternative to FileWatching.watch_folder. The differences are, in addition to those mentioned above for watch_file:


In fact, BetterFileWatching.watch_file and BetterFileWatching.watch_folder are actually just the same function! It handles both files and folders.