Franklin.jl — automatically evaluate `.jl` file on change

Sure! Here is an example on how I do this:

using FileWatching

@async while true 
    watch_file("./tmp.jl")
    println("Change Detected!")
end

This creates an asynchronous task in the background of your Julia REPL that can then run whatever command you want while you monitor a specific file (or folder). In this case, I am making the task print a statement that says “Change Detected!” to my REPL whenever there is a change in the file called “tmp.jl”. Here is a video showing blocking and asynchronous behavior:

watching_example

I also use this same process when working with Weave to generate Weave on a change and then I use the node package, browser-sync, to reload my browser upon change to view my Weave made report. Happy to share that too!

5 Likes