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