Skip to content
Browse files

+ Added a comment in README

+ Finished changing delete for remove.
  • Loading branch information...
1 parent eda2a73 commit c6a7408cce88e2d3218a9bc817070fe5a34054fb @krlito committed May 2, 2012
Showing with 10 additions and 8 deletions.
  1. +2 −1 README.md
  2. +7 −6 lib/filemonitor.js
  3. +1 −1 package.json
View
3 README.md
@@ -154,7 +154,8 @@ Another example for watching multiple files and excluding some others:
###Other comments...
- Once the `watch` function has been called, options cannot be changed.
- Monitoring can be stopped calling function `filemon.stop()`.
-
+- For monitoring a single file, it should be easier to use `watch`
+ in the standard file system node.js API.
[inotifywait]: http://github.com/rvoicilas/inotify-tools/wiki
[inotify-tools]: http://github.com/rvoicilas/inotify-tools/wiki
View
13 lib/filemonitor.js
@@ -96,15 +96,14 @@ var filemonitor = module.exports = {
* Manually trigger an event
*/
trigger: function(ev) {
- if (!options.dismissQueuedEvents || !queuedEvents[ev.filename + ":" + eventId]) {
- queuedEvents[ev.filename + ":" + eventId] = true;
+ if (!options.dismissQueuedEvents || !queuedEvents[ev.filename + ":" + ev.eventId]) {
+ queuedEvents[ev.filename + ":" + ev.eventId] = true;
if(!ev.timestamp) {ev.timestamp = new Date()};
-
process.nextTick(function () {
if (options.listeners.all_events) { options.listeners.all_events(ev); }
- if (options.listeners[eventId]) { options.listeners[eventId](ev); }
- queuedEvents[ev.filename + ":" + eventId] = null;
+ if (options.listeners[ev.eventId]) { options.listeners[ev.eventId](ev); }
+ queuedEvents[ev.filename + ":" + ev.eventId] = null;
});
}
}
@@ -128,6 +127,7 @@ function inotifywaitArgs() {
if (!options.listeners.all_events) {
for (listener in options.listeners) {
if (options.listeners.hasOwnProperty(listener)) {
+ listener = listener.replace("remove", "delete");
args.push("-e", listener);
}
}
@@ -158,10 +158,11 @@ function watchEvents(data) {
}
eventIds.forEach(function (eventId) {
+ eventId = eventId.replace("delete", "remove");
if (!options.dismissQueuedEvents || !queuedEvents[ev.filename + ":" + eventId]) {
queuedEvents[ev.filename + ":" + eventId] = true;
- ev.eventId = eventId.replace("delete", "remove");
+ ev.eventId = eventId;
ev.timestamp = new Date(ev.timestamp);
process.nextTick(function () {
View
2 package.json
@@ -1,7 +1,7 @@
{
"name": "filemonitor",
"description": "Monitor filesystem events in node.js. Watch for file changes and run callbacks.",
- "version": "0.1.2",
+ "version": "0.1.3",
"homepage": "http://github.com/krlito/filemonitor-node.git",
"author": "Carlos Campo <carlos@campo.com.co>",
"repository": {

0 comments on commit c6a7408

Please sign in to comment.
Something went wrong with that request. Please try again.