build(deps-dev): apply updates
[e-mobility-charging-stations-simulator.git] / build-requirements.js
CommitLineData
66a7748d 1import chalk from 'chalk'
8f801a93 2import { satisfies } from 'semver'
66a7748d 3import { version, exit } from 'node:process'
8fa6f565
JB
4import { readFileSync } from 'node:fs'
5
6const packageJson = JSON.parse(readFileSync('./package.json', 'utf8'))
1f7fa4de 7
67623aa6 8/**
fc040c43 9 * Check if the current node version match the required engines version.
67623aa6 10 */
1cee0015 11export const checkNodeVersion = () => {
66a7748d 12 const enginesNodeVersion = packageJson.engines.node
8f801a93 13 if (satisfies(version, enginesNodeVersion) === false) {
67623aa6
JB
14 console.error(
15 chalk.red(
412cece8 16 `Required node version ${enginesNodeVersion} not satisfied with current version ${version}`
66a7748d
JB
17 )
18 )
ef85c95a 19 // eslint-disable-next-line n/no-process-exit
66a7748d 20 exit(1)
67623aa6 21 }
66a7748d 22}
67623aa6 23
66a7748d 24checkNodeVersion()