Skip to content

Node.js based forum software built for the modern web

closed #2384

Julian Lam9b0ba6c7a4fb
diff --git a/src/plugins.js b/src/plugins.js
index 4d090d3df8..a4180880f1 100644
--- a/src/plugins.js
+++ b/src/plugins.js
@@ -746,7 +746,22 @@ var fs = require('fs'),
};
Plugins.clearRequireCache = function(next) {
- async.map(Plugins.libraryPaths, fs.realpath, function(err, paths) {
+ var cached = Object.keys(require.cache);
+ async.waterfall([
+ async.apply(async.map, Plugins.libraryPaths, fs.realpath),
+ function(paths, next) {
+ paths = paths.map(function(pluginLib) {
+ var parent = path.dirname(pluginLib);
+ return cached.filter(function(libPath) {
+ return libPath.indexOf(parent) !== -1;
+ });
+ }).reduce(function(prev, cur) {
+ return prev.concat(cur);
+ });
+ next(null, paths);
+ }
+ ], function(err, paths) {
+ console.log(paths);
for (var x=0,numPaths=paths.length;x<numPaths;x++) {
delete require.cache[paths[x]];
}