Coder Social home page Coder Social logo

watcher's Introduction

watcher

Build Status

Crystal shard to watch file changes. This shard use the same code implemented here (Guardian) and here (Sentry).

Installation

Add this to your application's shard.yml:

dependencies:
  watcher:
    github: faustinoaq/watcher

Usage

Use the keyword watch to watch files or file groups, for example:

require "watcher"

watch "src/assets/js/*.js" do |event|
  event.on_change do |files|
    files.each do |file, {first, timestamp}|
      puts "File #{file} has changed at #{timestamp}"
    end
    # ...
  end
end

Also you can have more than one watcher, just use spawn

spawn do
  watch ["src/assets/*.css", "src/views/*.html"] do |event|
    event.on_change do
      # ...
    end
  end
end

# Other watcher
watch ... do |event|
 #...
end

And you can change time interval for a watcher.

watch "public/*.json", interval: 0.5 do |event|
  event.on_change do
    # ...
  end
end

Also you can use Watcher.watch instead of watch.

How does it work?

Watcher uses timestamps to check file changes every second, if you want some more advanced then you can use Watchbird that uses libnotify to check events like modify, access and delete but just work in Linux for now.

Contributing

  1. Fork it ( https://github.com/faustinoaq/watcher/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • faustinoaq Faustino Aguilar - creator, maintainer

watcher's People

Contributors

furkan-firat avatar

Stargazers

Wout avatar Mike avatar Iain Barnett avatar  avatar  avatar Sergey Fedorov avatar  avatar Onofre Souza avatar Youssef Idmoussi avatar Mark Molnar avatar Nob avatar Julien Reichardt avatar Robin Michael avatar Slava Dzyba avatar Armando Magalhães avatar flxy avatar Ragmaanir avatar Anton Maminov avatar Kent Gruber avatar Matt Petty avatar Alexander ADAM avatar

Watchers

James Cloos avatar  avatar

watcher's Issues

Wathcer logo offer

Hi sir. I want to contribute for watcher. I degined a logo for readme file.

Logo Idea: watch file changes... If you want it, i will send a pull-request. Please fedback me. Good works!

watcher

Stuck in a loop

At some point this seems to have stopped working - and now the watcher thinks that the files have changed continuously even though there were no file changes.

on every loop the event._on_change reports the file landing.html has changed but it hasn't

  1. "src/webapp/public/landing.html" => {true, "20191009174705.775"}
  2. "src/webapp/public/landing.html" => {true, "20191009174705.775"}
    3 ... and forever etc

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.