Skip to content
Snippets Groups Projects
Commit c19b73a8 authored by João Victor Tozatti Risso's avatar João Victor Tozatti Risso
Browse files

Add middleware to check for the appropriate Node version

- Add middleware to check for the appropriate Node version. This relies on the
engines.node flag being set on package.json.
parent 8ba2635e
No related branches found
No related tags found
1 merge request!116Release v1.0.0
const curPath = process.cwd();
const libs = `${process.cwd()}/libs`;
const log = require(`${libs}/log`)(module);
const chalk = require('chalk');
const packageConf = require(`${curPath}/package.json`);
module.exports = () => {
// Parse version number from strings such as 'v4.2.0' or `>=4.0.0'
function parseVersionNumber(versionString) {
return parseFloat(versionString.replace(/[^\d\.]/g, ''));
}
// Ensure minimum supported node version is used
const minNodeVersion = parseVersionNumber(packageConf.engines.node);
const currentNodeVersion = parseVersionNumber(process.version);
if (minNodeVersion > currentNodeVersion) {
log.error(chalk.red(`You must upgrade node to >=${minNodeVersion}.x to use simcaq-node!`));
return false;
} else {
log.info('Node version should work!');
return true;
}
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment