Skip to content

Commit

Permalink
Merge pull request Zagrios#215 from Zagrios/hotfix/unable-to-launch
Browse files Browse the repository at this point in the history
[hotfix] fix unable to launch due to tasklist returning nothing
  • Loading branch information
Zagrios authored Apr 12, 2023
2 parents 3b6e908 + 28a5576 commit 27e5d79
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/main/services/bs-launcher.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ export class BSLauncherService{
}

public isBsRunning(): boolean{
return this.bsProcess?.connected || this.utilsService.taskRunning(BS_EXECUTABLE);
return this.bsProcess?.connected || this.utilsService.taskRunning(BS_EXECUTABLE) === true;
}

public async launch(launchOptions: LauchOption): Promise<LaunchResult>{
if(launchOptions.version.oculus && !this.oculusService.oculusRunning()){ return "OCULUS_NOT_RUNNING" }
if(!launchOptions.version.oculus && !this.steamService.steamRunning()){ return "STEAM_NOT_RUNNING" }
if(this.isBsRunning()){ return "BS_ALREADY_RUNNING" }
if(launchOptions.version.oculus && this.oculusService.oculusRunning() === false){ return "OCULUS_NOT_RUNNING" }
if(!launchOptions.version.oculus && this.steamService.steamRunning() === false){ return "STEAM_NOT_RUNNING" }
if(this.isBsRunning() === true){ return "BS_ALREADY_RUNNING" }

const cwd = await this.localVersionService.getVersionPath(launchOptions.version);
const exePath = path.join(cwd, BS_EXECUTABLE);
Expand Down
2 changes: 1 addition & 1 deletion src/main/services/oculus.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class OculusService {
this.utils = UtilsService.getInstance();
}

public oculusRunning(): boolean{
public oculusRunning(): boolean | null{
return this.utils.taskRunning("OculusClient.exe");
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/services/steam.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class SteamService{
return SteamService.instance;
}

public steamRunning(): boolean{
public steamRunning(): boolean | null{
return this.utils.taskRunning('steam.exe');
}

Expand Down
14 changes: 10 additions & 4 deletions src/main/services/utils.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,16 @@ export class UtilsService{
public setMainWindows(windows: Map<AppWindow, BrowserWindow>){ this.windows = windows; }
public getMainWindows(win: AppWindow){ return this.windows.get(win); }

public taskRunning(task: string): boolean{
const tasks = spawnSync('tasklist').stdout.toString();
return tasks.includes(task);
}
public taskRunning(task: string): boolean | null{
try{
const tasks = spawnSync('tasklist').stdout;
return tasks.toString().includes(task);
}
catch(error){
log.error(error);
return null;
}
}

public ipcSend<T = any>(channel: string, response: IpcResponse<T>): void{
try {
Expand Down

0 comments on commit 27e5d79

Please sign in to comment.