Skip to content

Node.js based forum software built for the modern web

some prep work to allow for checking of dependency versions. Also updated upgrade.check behaviour to send back error if schema is out of date, instead of no error and "false".

Julian Lam1069f9c936d4
diff --git a/app.js b/app.js
index cd0a566fa4..bb81d91698 100644
--- a/app.js
+++ b/app.js
@@ -182,16 +182,13 @@ function start() {
function(next) {
require('./src/meta').configs.init(next);
},
+ function(next) {
+ return next(new Error('dependencies-out-of-date'));
+ },
function(next) {
require('./src/upgrade').check(next);
},
- function(schema_ok, next) {
- if (!schema_ok && nconf.get('check-schema') !== false) {
- winston.warn('Your NodeBB schema is out-of-date. Please run the following command to bring your dataset up to spec:');
- winston.warn(' ./nodebb upgrade');
- process.exit();
- return;
- }
+ function(next) {
var webserver = require('./src/webserver');
require('./src/socket.io').init(webserver.server);
@@ -204,12 +201,25 @@ function start() {
}
], function(err) {
if (err) {
- if (err.stacktrace !== false) {
- winston.error(err.stack);
- } else {
- winston.error(err.message);
+ switch(err.message) {
+ case 'schema-out-of-date':
+ winston.warn('Your NodeBB schema is out-of-date. Please run the following command to bring your dataset up to spec:');
+ winston.warn(' ./nodebb upgrade');
+ break;
+ case 'dependencies-out-of-date':
+ winston.warn('One or more of NodeBB\'s dependent packages are out-of-date. Please run the following command to update them:');
+ winston.warn(' ./nodebb upgrade');
+ break;
+ default:
+ if (err.stacktrace !== false) {
+ winston.error(err.stack);
+ } else {
+ winston.error(err.message);
+ }
+ break;
}
+ // Either way, bad stuff happened. Abort start.
process.exit();
}
});
diff --git a/src/upgrade.js b/src/upgrade.js
index 1fdbd984f7..33f8dccd1c 100644
--- a/src/upgrade.js
+++ b/src/upgrade.js
@@ -34,12 +34,13 @@ Upgrade.check = function(callback) {
if (err) {
return callback(err);
}
- callback(null, true);
+ callback(null);
});
return;
}
- callback(null, parseInt(value, 10) >= latestSchema);
+ var schema_ok = parseInt(value, 10) >= latestSchema;
+ callback(!schema_ok ? new Error('schema-out-of-date') : null);
});
};