mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 15:36:16 -04:00
NodeVersion.js: do not use callbacks, simplify calling style in server.js
This commit is contained in:
parent
36addd2205
commit
9d9b7c9faf
2 changed files with 16 additions and 18 deletions
|
@ -28,6 +28,17 @@ var log4js = require('log4js')
|
||||||
|
|
||||||
log4js.replaceConsole();
|
log4js.replaceConsole();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* early check for version compatibility before calling
|
||||||
|
* any modules that require newer versions of NodeJS
|
||||||
|
*/
|
||||||
|
NodeVersion.enforceMinNodeVersion('6.9.0');
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Since Etherpad 1.8.0, at least NodeJS 8.9.0 will be required
|
||||||
|
*/
|
||||||
|
NodeVersion.checkDeprecationStatus('8.9.0', '1.8.0');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* start up stats counting system
|
* start up stats counting system
|
||||||
*/
|
*/
|
||||||
|
@ -43,16 +54,6 @@ var settings
|
||||||
var npm = require("npm/lib/npm.js");
|
var npm = require("npm/lib/npm.js");
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function(callback)
|
|
||||||
{
|
|
||||||
NodeVersion.enforceMinNodeVersion('6.9.0', callback);
|
|
||||||
},
|
|
||||||
|
|
||||||
function(callback)
|
|
||||||
{
|
|
||||||
NodeVersion.checkDeprecationStatus('8.9.0', '1.8.0', callback);
|
|
||||||
},
|
|
||||||
|
|
||||||
// load npm
|
// load npm
|
||||||
function(callback) {
|
function(callback) {
|
||||||
npm.load({}, function(er) {
|
npm.load({}, function(er) {
|
||||||
|
|
|
@ -24,19 +24,18 @@ const semver = require('semver');
|
||||||
* Quits if Etherpad is not running on a given minimum Node version
|
* Quits if Etherpad is not running on a given minimum Node version
|
||||||
*
|
*
|
||||||
* @param {String} minNodeVersion Minimum required Node version
|
* @param {String} minNodeVersion Minimum required Node version
|
||||||
* @param {Function} callback Standard callback function
|
|
||||||
*/
|
*/
|
||||||
exports.enforceMinNodeVersion = function(minNodeVersion, callback) {
|
exports.enforceMinNodeVersion = function(minNodeVersion) {
|
||||||
const currentNodeVersion = process.version;
|
const currentNodeVersion = process.version;
|
||||||
|
|
||||||
// we cannot use template literals, since we still do not know if we are
|
// we cannot use template literals, since we still do not know if we are
|
||||||
// running under Node >= 4.0
|
// running under Node >= 4.0
|
||||||
if (semver.lt(currentNodeVersion, minNodeVersion)) {
|
if (semver.lt(currentNodeVersion, minNodeVersion)) {
|
||||||
console.error('Running Etherpad on Node ' + currentNodeVersion + ' is not supported. Please upgrade at least to Node ' + minNodeVersion);
|
console.error('Running Etherpad on Node ' + currentNodeVersion + ' is not supported. Please upgrade at least to Node ' + minNodeVersion);
|
||||||
} else {
|
process.exit(1);
|
||||||
console.debug('Running on Node ' + currentNodeVersion + ' (minimum required Node version: ' + minNodeVersion + ')');
|
|
||||||
callback();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.debug('Running on Node ' + currentNodeVersion + ' (minimum required Node version: ' + minNodeVersion + ')');
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,12 +44,10 @@ exports.enforceMinNodeVersion = function(minNodeVersion, callback) {
|
||||||
* @param {String} lowestNonDeprecatedNodeVersion all Node version less than this one are deprecated
|
* @param {String} lowestNonDeprecatedNodeVersion all Node version less than this one are deprecated
|
||||||
* @param {Function} epRemovalVersion Etherpad version that will remove support for deprecated Node releases
|
* @param {Function} epRemovalVersion Etherpad version that will remove support for deprecated Node releases
|
||||||
*/
|
*/
|
||||||
exports.checkDeprecationStatus = function(lowestNonDeprecatedNodeVersion, epRemovalVersion, callback) {
|
exports.checkDeprecationStatus = function(lowestNonDeprecatedNodeVersion, epRemovalVersion) {
|
||||||
const currentNodeVersion = process.version;
|
const currentNodeVersion = process.version;
|
||||||
|
|
||||||
if (semver.lt(currentNodeVersion, lowestNonDeprecatedNodeVersion)) {
|
if (semver.lt(currentNodeVersion, lowestNonDeprecatedNodeVersion)) {
|
||||||
console.warn(`Support for Node ${currentNodeVersion} will be removed in Etherpad ${epRemovalVersion}. Please consider updating at least to Node ${lowestNonDeprecatedNodeVersion}`);
|
console.warn(`Support for Node ${currentNodeVersion} will be removed in Etherpad ${epRemovalVersion}. Please consider updating at least to Node ${lowestNonDeprecatedNodeVersion}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
callback();
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue