build(deps-dev): apply updates
[e-mobility-charging-stations-simulator.git] / build-requirements.js
... / ...
CommitLineData
1import chalk from 'chalk'
2import { satisfies } from 'semver'
3import { version, exit } from 'node:process'
4import { readFileSync } from 'node:fs'
5
6const packageJson = JSON.parse(readFileSync('./package.json', 'utf8'))
7
8/**
9 * Check if the current node version match the required engines version.
10 */
11export 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
24checkNodeVersion()