Improved working directory switch.

This commit is contained in:
Ylian Saint-Hilaire 2020-01-29 15:29:15 -08:00
parent 0a24f24959
commit 870ef4c279
1 changed files with 2 additions and 3 deletions

View File

@ -2281,9 +2281,8 @@ function mainStart() {
// Check the NodeJS is version 6 or better.
if (Number(process.version.match(/^v(\d+\.\d+)/)[1]) < 6) { console.log("MeshCentral requires Node v6 or above, current version is " + process.version + "."); return; }
// If running within the node_modules folder, move working directory back to parent.
if (process.cwd().endsWith('\\node_modules\\meshcentral') || process.cwd().endsWith('/node_modules/meshcentral')) { process.chdir(require('path').join(process.cwd(), '..', '..')); }
if (process.cwd().endsWith('\\node_modules') || process.cwd().endsWith('/node_modules')) { process.chdir(require('path').join(process.cwd(), '..')); }
// If running within the node_modules folder, move working directory to the parent of the node_modules folder.
if (__dirname.endsWith('\\node_modules\\meshcentral') || __dirname.endsWith('/node_modules/meshcentral')) { process.chdir(require('path').join(__dirname, '..', '..')); }
// Check for any missing modules.
InstallModules(['minimist'], function () {