From 603018d1efa1e6f065c66a6b8c12a424b4f69d60 Mon Sep 17 00:00:00 2001 From: Pax1601 Date: Tue, 19 Dec 2023 18:39:35 +0100 Subject: [PATCH] Added argument to vbs script --- client/client.js | 13 +++++++++---- client/client.vbs | 2 +- client/server.bat | 1 + 3 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 client/server.bat diff --git a/client/client.js b/client/client.js index da0609ea..59bb0455 100644 --- a/client/client.js +++ b/client/client.js @@ -2,13 +2,18 @@ const { app, BrowserWindow } = require('electron/main') const path = require('path') const fs = require('fs') const { spawn } = require('child_process'); +const yargs = require('yargs'); -const jsonPath = ("..", "olympus.json"); +yargs.alias('c', 'config').describe('c', 'olympus.json config location').string('rp'); +args = yargs.argv; + +console.log(`Config location: ${args["config"]}`) var clientPort = 3000; - -if (fs.existsSync(jsonPath)) { - var json = JSON.parse(fs.readFileSync(jsonPath, 'utf-8')); +if (fs.existsSync(args["config"])) { + var json = JSON.parse(fs.readFileSync(args["config"], 'utf-8')); clientPort = json["client"]["port"]; +} else { + console.log("Failed to read config, trying default port"); } function createWindow() { diff --git a/client/client.vbs b/client/client.vbs index 71b43971..53d57aaf 100644 --- a/client/client.vbs +++ b/client/client.vbs @@ -1 +1 @@ -CreateObject("Wscript.Shell").Run "npm run client", 0 \ No newline at end of file +CreateObject("Wscript.Shell").Run "npm run client -- --config """&WScript.Arguments(0)&"""", 1 \ No newline at end of file diff --git a/client/server.bat b/client/server.bat new file mode 100644 index 00000000..78386a02 --- /dev/null +++ b/client/server.bat @@ -0,0 +1 @@ +node .\\bin\\www \ No newline at end of file