Commit | Line | Data |
---|---|---|
1f7fa4de | 1 | const chalk = require('chalk'); |
ef85c95a | 2 | // eslint-disable-next-line n/no-unpublished-require |
1f7fa4de JB |
3 | const SemVer = require('semver'); |
4 | ||
5 | const enginesNodeVersion = require('./package.json').engines.node; | |
6 | ||
67623aa6 | 7 | /** |
fc040c43 | 8 | * Check if the current node version match the required engines version. |
67623aa6 JB |
9 | */ |
10 | function checkNodeVersion() { | |
11 | if (SemVer.satisfies(process.version, enginesNodeVersion) === false) { | |
12 | console.error( | |
13 | chalk.red( | |
14 | `Required node version ${enginesNodeVersion} not satisfied with current version ${process.version}.` | |
15 | ) | |
16 | ); | |
ef85c95a | 17 | // eslint-disable-next-line n/no-process-exit |
67623aa6 JB |
18 | process.exit(1); |
19 | } | |
1f7fa4de | 20 | } |
67623aa6 JB |
21 | |
22 | checkNodeVersion(); | |
23 | ||
24 | module.exports = { checkNodeVersion }; |