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