Reputation: 7317
Every time a source file changes, I'd like to run a command in my currently running running clojure repl. This is similar to people running a bash command upon file changes (i.e., rebuilding their project when a file changes). Is this possible?
Upvotes: 2
Views: 235
Reputation: 3801
Take a look at the Prism library. Specifically the watch!
function should let you do what you need.
Upvotes: 1
Reputation: 13185
You can use clojure/tools.namespace and its clojure.tools.namespace.repl/refresh
function providing it the :after
option pointing to your function:
(refresh :after 'some-ns/some-fn)
From now on tools.namespace
will watch your source files and reload relevant namespaces if they change and call your function after reloading.
Upvotes: 1