Skip to content

Commit

Permalink
[fix refactor] Use watch.watchTree function
Browse files Browse the repository at this point in the history
We want to listen on all events, so it's better to use `watch.watchTree`
than `watch.createMonitor`.
  • Loading branch information
mmalecki committed Oct 1, 2011
1 parent 1b02785 commit b9b3129
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions lib/forever/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,17 +394,20 @@ Monitor.prototype.watch = function () {
Array.prototype.push.apply(self.watchIgnorePatterns, data.split('\n'));
});

watch.createMonitor(
this.watchDirectory,
function (monitor) {
monitor.on('changed', function (f, curr, prev) {
if (self._watchFilter(f)) {
self.info('restaring script because ' + f + ' changed');
self.restart();
}
});
}
);
watch.watchTree(this.watchDirectory, function (f, curr, prev) {
if (!(curr == null && prev == null && typeof f == 'object')) {
//
// `curr` == null && `prev` == null && typeof f == "object" when watch
// finishes walking the tree to add listeners. We don't need to know
// about it, so we simply ignore it (anything different means that
// some file changed/was removed/created - that's what we want to know).
//
if (self._watchFilter(f)) {
self.info('restaring script because ' + f + ' changed');
self.restart();
}
};
});
};

//
Expand Down

0 comments on commit b9b3129

Please sign in to comment.