Making IPC port kwarg configurable; improving kwarhs filter out
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
const { app } = require('electron');
|
||||
|
||||
|
||||
let startType = "build";
|
||||
let isDebug = false;
|
||||
let args = [];
|
||||
let startType = "build";
|
||||
let ipcPort = "4563";
|
||||
let isDebug = false;
|
||||
let args = [];
|
||||
|
||||
|
||||
|
||||
@@ -17,6 +18,13 @@ const loadKWArgs = () => {
|
||||
console.log(startType);
|
||||
}
|
||||
|
||||
const hasIpcPort = app.commandLine.hasSwitch("ipc-port");
|
||||
if (hasIpcPort) {
|
||||
ipcPort = app.commandLine.getSwitchValue("ipc-port");
|
||||
console.log("Has ipc-port switch...");
|
||||
console.log(ipcPort);
|
||||
}
|
||||
|
||||
const hasDebug = app.commandLine.hasSwitch("app-debug");
|
||||
if (hasDebug) {
|
||||
isDebug = app.commandLine.getSwitchValue("app-debug");
|
||||
@@ -25,38 +33,29 @@ const loadKWArgs = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const loadVArgs = () => {
|
||||
console.log("\n\nStart VArgs:");
|
||||
|
||||
const filterOutLaunchAndKWArgs = () => {
|
||||
if (
|
||||
process.argv[0].endsWith("electron")
|
||||
) {
|
||||
process.argv = process.argv.slice(2);
|
||||
}
|
||||
|
||||
if (
|
||||
process.argv[0].endsWith("/newton") ||
|
||||
process.argv[0].endsWith(".AppImage")
|
||||
) {
|
||||
do {
|
||||
process.argv = process.argv.slice(1);
|
||||
}
|
||||
|
||||
if ( process.argv.length > 0 && (
|
||||
process.argv[0].includes("--trace-warnings") ||
|
||||
process.argv[0].includes("--start-as")
|
||||
} while (
|
||||
process.argv.length > 0 &&
|
||||
(
|
||||
process.argv[0].endsWith("/newton") ||
|
||||
process.argv[0].endsWith(".AppImage") ||
|
||||
process.argv[0].includes("--trace-warnings") ||
|
||||
process.argv[0].includes("--start-as") ||
|
||||
process.argv[0].includes("--ipc-port")
|
||||
)
|
||||
) {
|
||||
process.argv = process.argv.slice(1);
|
||||
}
|
||||
|
||||
if ( process.argv.length > 0 && (
|
||||
process.argv[0].includes("--trace-warnings") ||
|
||||
process.argv[0].includes("--start-as")
|
||||
)
|
||||
) {
|
||||
process.argv = process.argv.slice(1);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
const loadVArgs = () => {
|
||||
console.log("\n\nStart VArgs:");
|
||||
args = process.argv;
|
||||
args.forEach((val, index, array) => {
|
||||
console.log(index + ': ' + val);
|
||||
@@ -67,6 +66,7 @@ const loadVArgs = () => {
|
||||
|
||||
const loadArgs = () => {
|
||||
loadKWArgs();
|
||||
filterOutLaunchAndKWArgs();
|
||||
loadVArgs();
|
||||
}
|
||||
|
||||
@@ -83,6 +83,10 @@ const getDebugMode = () => {
|
||||
return isDebug;
|
||||
}
|
||||
|
||||
const getIpcPort = () => {
|
||||
return ipcPort;
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
argsParser: {
|
||||
@@ -90,5 +94,6 @@ module.exports = {
|
||||
getArgs: getArgs,
|
||||
getStartType: getStartType,
|
||||
getDebugMode: getDebugMode,
|
||||
getIpcPort: getIpcPort,
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user