Coder Social home page Coder Social logo

Comments (5)

thomasfl avatar thomasfl commented on September 26, 2024

The most natural thing seems to exit with a warning if a file is deleted. New gem has been pushed.

from filewatcher.

cprobert avatar cprobert commented on September 26, 2024

Thanks for the fix - appreciated.

Rather than exiting, what about having a deleted event. Listen does something like this:
https://github.com/guard/listen

from filewatcher.

thomasfl avatar thomasfl commented on September 26, 2024

Could you please suggest how to command line interface should behave when a file is deleted?

The listen gem have a nice API. One idea is to simply rewrite the CLI to use the listen gem. The command line interface for filewatcher was made to be somewhat simpler than https://github.com/guard/guard.

from filewatcher.

cprobert avatar cprobert commented on September 26, 2024

I prefer filewatcher because its simple and works with files as well as directories. Personally I wouldn't change the API. I'd have it run for any type of file event, e.g.

FileWatcher.new(["lib/"],"Watching files:").watch do |filename|
  puts "File event detected" + filename
  # this could be an change or delete
end

Alternatively for those that wanted to know the type of change event:

FileWatcher.new(["lib/"],"Watching files:").watch do |filename, type|
  puts "File event detected" + filename
  # where type = changed, deleted, etc.
end

Just a suggestion :) Thanks for the lib

from filewatcher.

thomasfl avatar thomasfl commented on September 26, 2024

I've pushed out a new version that detect deleted files just like you suggested. Please tell me what you think.

FileWatcher.new(["lib/"],"Watching files:").watch do |filename|
  puts "File event detected" + filename
  # this could be an change or delete
end

It is also possible to detect events:

FileWatcher.new(["lib/"],"Watching files:").watch do |filename, type|
  puts "File event detected" + filename
  # where type = :changed or :deleted
end

When a file is deleted, it won't be checked again by filewatcher.

from filewatcher.

Related Issues (20)

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.