A babashka pod for watching files. Implemented using the Rust notify library.
The following installation methods are available:
- Download a binary from Github releases
- With brew:
brew install borkdude/brew/pod-babashka-filewatcher
Run in babashka or using the babashka.pods library on the JVM.
(require '[babashka.pods :as pods])
(pods/load-pod "pod-babashka-filewatcher")
(require '[pod.babashka.filewatcher :as fw])
(fw/watch "/tmp" (fn [event] (prn event)) {:delay-ms 50}))
As a result of the following terminal sequence:
$ touch created.txt
$ mv created.txt created_renamed.txt
$ chmod -w created_renamed.txt
$ chmod +w created_renamed.txt
$ echo "foo" >> created_renamed.txt
the following will be printed:
{:path "/private/tmp/created.txt", :type :create}
{:path "/private/tmp/created.txt", :type :notice/remove}
{:dest "/private/tmp/created_renamed.txt", :path "/private/tmp/created.txt", :type :rename}
{:path "/private/tmp/created_renamed.txt", :type :chmod}
{:path "/private/tmp/created_renamed.txt", :type :chmod}
{:path "/private/tmp/created_renamed.txt", :type :notice/write}
{:path "/private/tmp/created_renamed.txt", :type :write}
$ cargo build --release
Running tests requires clojure.
$ script/test
Copyright © 2020 Michiel Borkent
Distributed under the EPL License. See LICENSE.