Browse files

Merge pull request #162 from appleifreak/master

Implemented chokidar for more robust file system watching
  • Loading branch information...
2 parents 7505f27 + 9ab1e76 commit a8115c76858dd865164d7e712907bed521aa298d @jlongster committed Feb 24, 2014
Showing with 7 additions and 4 deletions.
  1. +2 −1 package.json
  2. +5 −3 src/node-loaders.js
View
3 package.json
@@ -4,7 +4,8 @@
"version": "1.0.1",
"author": "James Long <longster@gmail.com>",
"dependencies": {
- "optimist": "*"
+ "optimist": "*",
+ "chokidar": "git://github.com/appleifreak/chokidar.git"
},
"devDependencies": {
"expect.js": "*",
View
8 src/node-loaders.js
@@ -2,6 +2,7 @@ var fs = require('fs');
var path = require('path');
var lib = require('./lib');
var Loader = require('./loader');
+var chokidar = require('chokidar');
// Node <0.7.1 compatibility
var existsSync = fs.existsSync || path.existsSync;
@@ -24,9 +25,10 @@ var FileSystemLoader = Loader.extend({
// they change
lib.each(this.searchPaths, function(p) {
if(existsSync(p)) {
- fs.watch(p, { persistent: false }, function(event, filename) {
- var fullname = path.join(p, filename || '');
- if((event == 'change' || event == 'rename') && fullname in this.pathsToNames) {
+ var watcher = chokidar.watch(p, { ignoreInitial: true, usePolling: false });
+
+ watcher.on("all", function(event, fullname) {
+ if(event == "change" && fullname in this.pathsToNames) {
this.emit('update', this.pathsToNames[fullname]);
}
}.bind(this));

0 comments on commit a8115c7

Please sign in to comment.