Skip to content

Commit

Permalink
+ Added a comment in README
Browse files Browse the repository at this point in the history
+ Finished changing delete for remove.
  • Loading branch information
Carlos Campo committed May 2, 2012
1 parent eda2a73 commit c6a7408
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions lib/filemonitor.js
Expand Up @@ -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;
});
}
}
Expand All @@ -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);
}
}
Expand Down Expand Up @@ -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 () {
Expand Down
2 changes: 1 addition & 1 deletion 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": {
Expand Down

0 comments on commit c6a7408

Please sign in to comment.