X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=build-requirements.js;h=f73e3e89c642fbb315175cfd586e178108d8ac37;hb=e9f9bb186339de759bcf5d2eb1a82639268ff535;hp=63c471312cdf8c1445ac5aa497b90867c47ff021;hpb=ef85c95abf79b049e1cae653372bdf46b233dfac;p=e-mobility-charging-stations-simulator.git diff --git a/build-requirements.js b/build-requirements.js index 63c47131..f73e3e89 100644 --- a/build-requirements.js +++ b/build-requirements.js @@ -1,24 +1,22 @@ -const chalk = require('chalk'); -// eslint-disable-next-line n/no-unpublished-require -const SemVer = require('semver'); - -const enginesNodeVersion = require('./package.json').engines.node; +import chalk from 'chalk' +import { satisfies } from 'semver' +import packageJson from './package.json' assert { type: 'json' } +import { version, exit } from 'node:process' /** * Check if the current node version match the required engines version. */ -function checkNodeVersion() { - if (SemVer.satisfies(process.version, enginesNodeVersion) === false) { +export const checkNodeVersion = () => { + const enginesNodeVersion = packageJson.engines.node + if (satisfies(version, enginesNodeVersion) === false) { console.error( chalk.red( - `Required node version ${enginesNodeVersion} not satisfied with current version ${process.version}.` + `Required node version ${enginesNodeVersion} not satisfied with current version ${version}` ) - ); + ) // eslint-disable-next-line n/no-process-exit - process.exit(1); + exit(1) } } -checkNodeVersion(); - -module.exports = { checkNodeVersion }; +checkNodeVersion()