From 9105a6efa1a3c1f1bb5ceef5849b84e8529146e5 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sun, 2 Jan 2022 11:57:10 +0200 Subject: [PATCH] Several changes - added env variables support in config file - fixed `Process.run()` method work with env variables - changed a bit `Domain.getInfo()` method --- src/defaultSettings.ts | 7 +++++++ src/ts/core/Domain.ts | 35 ++++++++++++++++++++++---------- src/ts/launcher/states/Launch.ts | 10 +++++++-- src/ts/neutralino/Process.ts | 2 +- 4 files changed, 40 insertions(+), 14 deletions(-) diff --git a/src/defaultSettings.ts b/src/defaultSettings.ts index 44e788d..d58a6ce 100644 --- a/src/defaultSettings.ts +++ b/src/defaultSettings.ts @@ -29,6 +29,13 @@ promisify(async () => { * @default null */ dxvk: null, + + /** + * Environment variables + * + * @default null + */ + env: null, /** * Launcher theme diff --git a/src/ts/core/Domain.ts b/src/ts/core/Domain.ts index 359372e..35ff86f 100644 --- a/src/ts/core/Domain.ts +++ b/src/ts/core/Domain.ts @@ -22,23 +22,36 @@ export default class Domain process.output((outputPart) => { output += outputPart; - const regex = /PING (.*) \(([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})\) from ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}) : [\d]+\([\d]+\) bytes of data/gm.exec(output); - - if (regex !== null || output.includes('Name or service not known')) - { + const resolveInfo = (info: DomainInfo) => { process.outputInterval = null; process.runningInterval = null; - - const info: DomainInfo = { - uri: regex ? regex[1] : uri, - remoteIp: regex ? regex[2] : undefined, - localIp: regex ? regex[3] : undefined, - available: regex ? regex[2] !== regex[3] : false - }; debugThread.log({ message: info }); resolve(info); + }; + + if (output.includes('Name or service not known')) + { + resolveInfo({ + uri: uri, + available: false + }); + } + + else + { + const regex = /PING (.*) \(([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})\) from ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}) : [\d]+\([\d]+\) bytes of data/gm.exec(output); + + if (regex !== null) + { + resolveInfo({ + uri: regex[1], + remoteIp: regex[2], + localIp: regex[3], + available: regex[2] !== regex[3] + }); + } } }); }); diff --git a/src/ts/launcher/states/Launch.ts b/src/ts/launcher/states/Launch.ts index 219eab1..27ba12e 100644 --- a/src/ts/launcher/states/Launch.ts +++ b/src/ts/launcher/states/Launch.ts @@ -124,6 +124,12 @@ export default (): Promise => { const command = `'${Process.addSlashes(wineExeutable)}' launcher.bat`; + console.log({ + WINEPREFIX: await constants.paths.prefix.current, + ...env, + ...((await Configs.get('env') as object|null) ?? {}) + }); + /** * Starting the game */ @@ -131,9 +137,9 @@ export default (): Promise => { const process = await Process.run(command, { env: { + WINEPREFIX: await constants.paths.prefix.current, ...env, - - WINEPREFIX: await constants.paths.prefix.current + ...((await Configs.get('env') as object|null) ?? {}) }, cwd: await constants.paths.gameDir }); diff --git a/src/ts/neutralino/Process.ts b/src/ts/neutralino/Process.ts index 3971307..cc3f984 100644 --- a/src/ts/neutralino/Process.ts +++ b/src/ts/neutralino/Process.ts @@ -185,7 +185,7 @@ class Process if (options.env) { Object.keys(options.env).forEach((key) => { - command = `${key}='${this.addSlashes(options.env![key])}' ${command}`; + command = `${key}='${this.addSlashes(options.env![key].toString())}' ${command}`; }); }