mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2024-12-30 05:28:15 +03:00
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:
parent
2587b29b40
commit
9105a6efa1
4 changed files with 40 additions and 14 deletions
|
@ -30,6 +30,13 @@ promisify(async () => {
|
|||
*/
|
||||
dxvk: null,
|
||||
|
||||
/**
|
||||
* Environment variables
|
||||
*
|
||||
* @default null
|
||||
*/
|
||||
env: null,
|
||||
|
||||
/**
|
||||
* Launcher theme
|
||||
*
|
||||
|
|
|
@ -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]
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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
|
||||
});
|
||||
|
|
|
@ -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}`;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue