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