Skip to content

Node.js based forum software built for the modern web

Reduce verbosity of plugin incompatibility errors

Julian Lame382dcab135d
diff --git a/src/plugins.js b/src/plugins.js
index d2a726096b..046809e76e 100644
--- a/src/plugins.js
+++ b/src/plugins.js
@@ -31,6 +31,7 @@ var fs = require('fs'),
Plugins.clientScripts = [];
Plugins.customLanguages = [];
Plugins.libraryPaths = [];
+ Plugins.versionWarning = [];
Plugins.initialized = false;
@@ -74,6 +75,7 @@ var fs = require('fs'),
Plugins.libraries = {};
Plugins.loadedHooks = {};
Plugins.staticDirs = {};
+ Plugins.versionWarning = [];
Plugins.cssFiles.length = 0;
Plugins.lessFiles.length = 0;
Plugins.clientScripts.length = 0;
@@ -106,6 +108,16 @@ var fs = require('fs'),
});
},
function(next) {
+ // If some plugins are incompatible, throw the warning here
+ if (Plugins.versionWarning.length) {
+ process.stdout.write('\n');
+ winston.warn('[plugins/load] The following plugins may not be compatible with your version of NodeBB. This may cause unintended behaviour or crashing. In the event of an unresponsive NodeBB caused by this plugin, run `./nodebb reset -p PLUGINNAME` to disable it.');
+ for(var x=0,numPlugins=Plugins.versionWarning.length;x<numPlugins;x++) {
+ process.stdout.write(' * '.yellow + Plugins.versionWarning[x].reset + '\n');
+ }
+ process.stdout.write('\n');
+ }
+
Object.keys(Plugins.loadedHooks).forEach(function(hook) {
var hooks = Plugins.loadedHooks[hook];
hooks = hooks.sort(function(a, b) {
diff --git a/src/plugins/load.js b/src/plugins/load.js
index 351ef638e5..ad441a2b97 100644
--- a/src/plugins/load.js
+++ b/src/plugins/load.js
@@ -20,7 +20,7 @@ module.exports = function(Plugins) {
return callback(pluginPath.match('nodebb-theme') ? null : err);
}
- versionWarning(pluginData);
+ checkVersion(pluginData);
async.parallel([
function(next) {
@@ -53,20 +53,19 @@ module.exports = function(Plugins) {
});
};
- function versionWarning(pluginData) {
- function display() {
- process.stdout.write('\n');
- winston.warn('[plugins/' + pluginData.id + '] This plugin may not be compatible with your version of NodeBB. This may cause unintended behaviour or crashing.');
- winston.warn('[plugins/' + pluginData.id + '] In the event of an unresponsive NodeBB caused by this plugin, run ./nodebb reset -p ' + pluginData.id + '.');
- process.stdout.write('\n');
+ function checkVersion(pluginData) {
+ function add() {
+ if (Plugins.versionWarning.indexOf(pluginData.id) === -1) {
+ Plugins.versionWarning.push(pluginData.id);
+ }
}
if (pluginData.nbbpm && pluginData.nbbpm.compatibility && semver.validRange(pluginData.nbbpm.compatibility)) {
if (!semver.satisfies(nconf.get('version'), pluginData.nbbpm.compatibility)) {
- display();
+ add();
}
} else {
- display();
+ add();
}
}