From 4b9e4a0109a5437d935250e8ecf0d21ecd7149c0 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 3 Oct 2014 17:29:42 -0400 Subject: [PATCH] closed #2224 --- src/meta.js | 1 + src/plugins.js | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/meta.js b/src/meta.js index 357c4a432e..9e7f398e3a 100644 --- a/src/meta.js +++ b/src/meta.js @@ -34,6 +34,7 @@ var async = require('async'), Meta.reload = function(callback) { async.series([ + async.apply(plugins.clearRequireCache), async.apply(plugins.reload), function(next) { async.parallel([ diff --git a/src/plugins.js b/src/plugins.js index 92e1a1bdb4..9ef88e4991 100644 --- a/src/plugins.js +++ b/src/plugins.js @@ -28,6 +28,7 @@ var fs = require('fs'), Plugins.lessFiles = []; Plugins.clientScripts = []; Plugins.customLanguages = []; + Plugins.libraryPaths = []; Plugins.initialized = false; @@ -76,11 +77,13 @@ var fs = require('fs'), Plugins.reload = function(callback) { // Resetting all local plugin data + Plugins.libraries = {}; Plugins.loadedHooks = {}; Plugins.staticDirs = {}; Plugins.cssFiles.length = 0; Plugins.lessFiles.length = 0; Plugins.clientScripts.length = 0; + Plugins.libraryPaths.length = 0; // Read the list of activated plugins and require their libraries async.waterfall([ @@ -186,6 +189,7 @@ var fs = require('fs'), if (exists) { if (!Plugins.libraries[pluginData.id]) { Plugins.libraries[pluginData.id] = require(libraryPath); + Plugins.libraryPaths.push(libraryPath); } // Register hooks for this plugin @@ -765,7 +769,16 @@ var fs = require('fs'), }); }; + Plugins.clearRequireCache = function(next) { + async.map(Plugins.libraryPaths, fs.realpath, function(err, paths) { + for (var x=0,numPaths=paths.length;x