diff --git a/lib/util/refresh.js b/lib/util/refresh.js new file mode 100644 index 00000000..c2be0ff0 --- /dev/null +++ b/lib/util/refresh.js @@ -0,0 +1,21 @@ +var fs = require('fs') + +var watchers = Object.create(null) + +function refresh() { + process.kill('SIGHUP') +} + +function collect() { + Object.keys(require.cache).forEach(function(path) { + if (!watchers[path]) { + if (path.indexOf('node_modules') === -1) { + watchers[path] = fs.watch(path, refresh) + } + } + }) +} + +module.exports = function() { + collect() +}