repositories
/
e-mobility-charging-stations-simulator.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
chore: version 1.3.7
[e-mobility-charging-stations-simulator.git]
/
build-requirements.js
diff --git
a/build-requirements.js
b/build-requirements.js
index 63c471312cdf8c1445ac5aa497b90867c47ff021..501933c4fa5ae659809f3ab8f96f13f710d4caa4 100644
(file)
--- a/
build-requirements.js
+++ b/
build-requirements.js
@@
-1,24
+1,26
@@
-const chalk = require('chalk');
-// eslint-disable-next-line n/no-unpublished-require
-const SemVer = require('semver');
+import { readFileSync } from 'node:fs'
+import { exit, version } from 'node:process'
-const enginesNodeVersion = require('./package.json').engines.node;
+import chalk from 'chalk'
+// eslint-disable-next-line n/no-unpublished-import
+import { satisfies } from 'semver'
+
+const packageJson = JSON.parse(readFileSync('./package.json', 'utf8'))
/**
* Check if the current node version match the required engines version.
*/
/**
* Check if the current node version match the required engines version.
*/
-function checkNodeVersion() {
- if (SemVer.satisfies(process.version, enginesNodeVersion) === false) {
+export const checkNodeVersion = () => {
+ const enginesNodeVersion = packageJson.engines.node
+ if (satisfies(version, enginesNodeVersion) === false) {
console.error(
chalk.red(
console.error(
chalk.red(
- `Required node version ${enginesNodeVersion} not satisfied with current version ${
process.version}.
`
+ `Required node version ${enginesNodeVersion} not satisfied with current version ${
version}
`
)
)
- )
;
+ )
// eslint-disable-next-line n/no-process-exit
// eslint-disable-next-line n/no-process-exit
- process.exit(1);
+ exit(1)
}
}
}
}
-checkNodeVersion();
-
-module.exports = { checkNodeVersion };
+checkNodeVersion()