v1.18.x
Julian Lam 10 years ago
parent 083ba12ee0
commit 9b0ba6c7a4

@ -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]];
}

Loading…
Cancel
Save