Several changes

- added env variables support in config file
- fixed `Process.run()` method work with env variables
- changed a bit `Domain.getInfo()` method
This commit is contained in:
Observer KRypt0n_ 2022-01-02 11:57:10 +02:00
parent 2587b29b40
commit 9105a6efa1
No known key found for this signature in database
GPG key ID: DC5D4EC1303465DA
4 changed files with 40 additions and 14 deletions

View file

@ -29,6 +29,13 @@ promisify(async () => {
* @default null
*/
dxvk: null,
/**
* Environment variables
*
* @default null
*/
env: null,
/**
* Launcher theme

View file

@ -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]
});
}
}
});
});

View file

@ -124,6 +124,12 @@ export default (): Promise<void> => {
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<void> => {
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
});

View file

@ -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}`;
});
}