runtime: enforce minimal node version to 6.9.0

Etherpad 1.6.6 does not run on node <= 5 already.
Node 6.9 is the first LTS release in the 6 series, and comes with npm 3.10.8.

Declarations in package.json are advisory unless the user has set
`engine-strict` config flag.

Updated the docs accordingly.
This commit is contained in:
muxator 2018-07-27 01:45:06 +02:00 committed by muxator
parent f1056bf01a
commit 7544585908
5 changed files with 50 additions and 4 deletions

View file

@ -24,6 +24,7 @@
var log4js = require('log4js')
, async = require('async')
, stats = require('./stats')
, NodeVersion = require('./utils/NodeVersion')
;
log4js.replaceConsole();
@ -39,6 +40,11 @@ var settings
var npm = require("npm/lib/npm.js");
async.waterfall([
function(callback)
{
NodeVersion.enforceMinNodeVersion('6.9.0', callback);
},
// load npm
function(callback) {
npm.load({}, function(er) {

View file

@ -0,0 +1,37 @@
/**
* Checks related to Node runtime version
*/
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Quits if Etherpad is not running on a given minimum Node version
*
* @param {String} minNodeVersion Minimum required Node version
* @param {Function} callback Standard callback function
*/
exports.enforceMinNodeVersion = function(minNodeVersion, callback) {
const semver = require('semver');
const currentNodeVersion = process.version;
// we cannot use template literals, since we still do not know if we are
// running under Node >= 4.0
if (semver.lt(currentNodeVersion, minNodeVersion)) {
console.error('Running Etherpad on Node ' + currentNodeVersion + ' is not supported. Please upgrade at least to Node ' + minNodeVersion);
} else {
console.debug('Running on Node ' + currentNodeVersion + ' (minimum required Node version: ' + minNodeVersion + ')');
callback();
}
};