mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
closed #2384
This commit is contained in:
@@ -746,7 +746,22 @@ var fs = require('fs'),
|
|||||||
};
|
};
|
||||||
|
|
||||||
Plugins.clearRequireCache = function(next) {
|
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++) {
|
for (var x=0,numPaths=paths.length;x<numPaths;x++) {
|
||||||
delete require.cache[paths[x]];
|
delete require.cache[paths[x]];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user