Add System check to beginning of node setup
This commit is contained in:
1 parent
f8d46316c4
commit
c22f1338ce
2 files changed
+50
No files matched your search
@@ -0,0 +1,46 @@
|
||||
const { execSync } = require("child_process");
|
||||
const os = require("os");
|
||||
|
||||
const npmNeededVersion = '5'
|
||||
const nodeNeededVersion = '12'
|
||||
const gitNeededVersion = '2'
|
||||
|
||||
function systemCheck () {
|
||||
try {
|
||||
|
||||
// Gather Installed Versions of Node, NPM and Git
|
||||
const npmVersionRaw = execSync( "npm -v",{ encoding: 'utf8', timeout: 30000 })
|
||||
const nodeVersionRaw = execSync( "node -v",{ encoding: 'utf8',timeout: 30000 })
|
||||
const gitVersionRaw = execSync( "git --version",{ encoding: 'utf8',timeout: 30000 })
|
||||
const npmVersion = npmVersionRaw.trim().split('.')
|
||||
const nodeVersion = nodeVersionRaw.trim().substring(1).split('.')
|
||||
const gitVersion = gitVersionRaw.trim().split(' ')[2].split('.')
|
||||
|
||||
// Check needed versions against those that are installed
|
||||
if ( npmVersion[0] < npmNeededVersion ) {
|
||||
console.log("ERROR: the version of npm you have installed is out of date. Please update your installation of npm and try again.")
|
||||
process.exit()
|
||||
}
|
||||
|
||||
if ( nodeVersion[0] < nodeNeededVersion ) {
|
||||
console.log("ERROR: the version of node you have installed is out of date. Please update your installation of node and try again.")
|
||||
process.exit()
|
||||
}
|
||||
|
||||
if ( gitVersion[0] < gitNeededVersion ) {
|
||||
console.log("ERROR: the version of git you have installed is out of date. Please update your installation of git and try again.")
|
||||
process.exit()
|
||||
}
|
||||
|
||||
|
||||
} catch (error) {
|
||||
console.log('');
|
||||
console.log("There was an error with your system: ");
|
||||
console.log('');
|
||||
console.log( error );
|
||||
return;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports = systemCheck
|
||||
@@ -1,6 +1,10 @@
|
||||
const path = require("path");
|
||||
const process = require("process");
|
||||
const { exec } = require("child_process");
|
||||
const systemCheck = require('./Launch-Scripts/system-check')
|
||||
|
||||
// Check system is set up correctly
|
||||
systemCheck();
|
||||
|
||||
// Handle adding shortcuts
|
||||
if (process.argv.includes("noShortcuts")) {
|
||||
|
||||
Reference in new issue
Block a user