-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
environmentChecks.js
33 lines (30 loc) · 1.05 KB
/
environmentChecks.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const { exec } = require('child_process');
function checkNodeVersion(requiredVersion) {
exec('node -v', (error, stdout, stderr) => {
if (error) {
console.error(`Error checking Node.js version: ${error}`);
return;
}
const installedVersion = stdout.trim();
if (installedVersion < requiredVersion) {
console.log(`Node.js version is too low. Required: ${requiredVersion}, Installed: ${installedVersion}`);
} else {
console.log(`Node.js version is adequate: ${installedVersion}`);
}
});
}
function checkNpmVersion(requiredVersion) {
exec('npm -v', (error, stdout, stderr) => {
if (error) {
console.error(`Error checking npm version: ${error}`);
return;
}
const installedVersion = stdout.trim();
if (installedVersion < requiredVersion) {
console.log(`npm version is too low. Required: ${requiredVersion}, Installed: ${installedVersion}`);
} else {
console.log(`npm version is adequate: ${installedVersion}`);
}
});
}
module.exports = { checkNodeVersion, checkNpmVersion };