Giter Site home page Giter Site logo

slimslenderslacks / pod-babashka-fswatcher Goto Github PK

View Code? Open in Web Editor NEW

This project forked from babashka/pod-babashka-fswatcher

0.0 0.0 0.0 37 KB

Babashka filewatcher pod.

License: BSD 3-Clause "New" or "Revised" License

Shell 0.93% Clojure 14.41% Go 81.44% Dockerfile 3.21%

pod-babashka-fswatcher's Introduction

pod-babashka-fswatcher

A babashka pod for watching files.

Implemented using the Go fsnotify library.

Status

Experimental.

Usage

Load the pod:

(require '[babashka.pods :as pods])
(pods/load-pod 'org.babashka/fswatcher "0.0.3")

(require '[pod.babashka.fswatcher :as fw])

Watchers can be created with fw/watch:

(def watcher (fw/watch "src" (fn [event] (prn event))))

You can create multiple watchers that run concurrently, even on the same directory.

The watch function returns a value which can be passed to unwatch which stops and cleans up the watcher:

(fw/unwatch watcher)

See test/script.clj for an example test script.

Usage in bb.edn

In babashka 0.8.0 it is possible to specify pods in bb.edn:

{:pods {org.babashka/fswatcher {:version "0.0.3"}}
 :tasks {watch {:requires ([pod.babashka.fswatcher :as fw])
                :task (do (fw/watch "project.clj"
                                    (fn [event]
                                      (when (#{:write :write|chmod} (:type event))
                                        (println "hello!"))))
                          (deref (promise)))}}}

Watch recursively

By default watchers do not watch recursively. Pass {:recursive true} in the options map to enable it.

(fw/watch "src" (fn [event] (prn event)) {:recursive true})

Build

Requirements

  • Go 1.18+ should be installed.
  • Clone this repo.
  • Run go build -o pod-babashka-fswatcher main.go to compile the binary.

License

Copyright © 2020 Rahul De and Michiel Borkent

License: BSD 3-Clause

pod-babashka-fswatcher's People

Contributors

lispyclouds avatar borkdude avatar aiba avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.