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

I understand that Franklin’s offline evaluation is meant to manually and outside of the live-evaluation workflow. Is there a way, however, to make Franklin watch for changes in a directory, and execute generate_results.jl anytime a file changes in a directory, or even better, execute genplain("scriptname.jl") each time scriptname.jl is updated?

Hey @mpf01 , may I ask what you are trying to do? I don’t know if Franklin does what you are saying but what I have done in the past is to deploy the Julia REPL, use FileWatching.jl, and then create an @async while loop that will trigger the execution of a script or function if a particular file or folder has detected a change.


Share your code!


Possibly Developer reference · Revise.jl may be useful.

You may also want to consider doing something like Generating auxiliary files with Literate . The literate path does check whether the underlying script changes.

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

using FileWatching

@async while true 
    println("Change Detected!")

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:


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!


Great solution, @TheCedarPrince. Thanks!

1 Like

No problem and glad I could help!

I decided to write a full blog post on this answer here: Asynchronous Workflow Using Julia Tutorial

Feel free to give it a look!