Permalink
Browse files

Added engine directory stucture with node implementation for file wat…

…ching
  • Loading branch information...
1 parent 26804d6 commit 98ecc21ec095d99b8fdeec444aeab34af90cabad Davis Clark committed Aug 13, 2010
Showing with 10 additions and 8 deletions.
  1. +1 −0 engines/node/lib/fileWatcher.js
  2. +9 −8 lib/view.js
View
1 engines/node/lib/fileWatcher.js
@@ -0,0 +1 @@
+exports.watchFile = require('fs').watchFile;
View
17 lib/view.js
@@ -1,11 +1,12 @@
var
- path = require('path'),
- http = require('http'),
- fs = require('fs'),
- extname = path.extname,
- promise = require('promised-io/promise'),
- when = promise.when,
- sys = require('sys');
+ path = require('path'),
+ http = require('http'),
+ fs = require('fs'),
+ extname = path.extname,
+ promise = require('promised-io/promise'),
+ when = promise.when,
+ sys = require('sys'),
+ watchFile = require('../engines/node/lib/fileWatcher').watchFile;
var ViewEngine = exports.ViewEngine = function(){};
@@ -33,7 +34,7 @@ ViewEngine.prototype.cacheView = function(path) {
doRead = function(path) { return promise.execute(fs.readFile, path, 'utf8'); },
doCache = function(str) { self.viewCache[path] = str; };
- fs.watchFile(path, function() { when(doRead(path), doCache) });
+ watchFile(path, function() { when(doRead(path), doCache) });
return when(doRead(path), function(str) { doCache(str); return str;});
};

0 comments on commit 98ecc21

Please sign in to comment.