mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
fix cannot read installed version when steam is not installed
This commit is contained in:
@@ -102,7 +102,7 @@ export class BSLocalVersionService{
|
||||
|
||||
public async getInstalledVersions(): Promise<BSVersion[]>{
|
||||
const versions: BSVersion[] = [];
|
||||
const steamBsFolder = await this.steamService.getGameFolder(BS_APP_ID, "Beat Saber")
|
||||
const steamBsFolder = await this.steamService.getGameFolder(BS_APP_ID, "Beat Saber");
|
||||
if(steamBsFolder && this.utilsService.pathExist(steamBsFolder)){
|
||||
const steamBsVersion = await this.getVersionOfBSFolder(steamBsFolder);
|
||||
if(steamBsVersion){
|
||||
|
||||
@@ -27,27 +27,31 @@ export class SteamService{
|
||||
}
|
||||
|
||||
public async getSteamPath(): Promise<string>{
|
||||
if(this.steamPath !== ''){ return this.steamPath; }
|
||||
|
||||
if(!!this.steamPath){ return this.steamPath; }
|
||||
|
||||
const [win32Res, win64Res] = await Promise.all([
|
||||
regedit.promisified.list(['HKLM\\SOFTWARE\\Valve\\Steam']),
|
||||
regedit.promisified.list(['HKLM\\SOFTWARE\\WOW6432Node\\Valve\\Steam'])
|
||||
]);
|
||||
|
||||
const [win32, win64] = [win32Res["HKLM\\SOFTWARE\\Valve\\Steam"], win64Res["HKLM\\SOFTWARE\\WOW6432Node\\Valve\\Steam"]];
|
||||
let res = ''
|
||||
if(win64.values.InstallPath.value){ res = win64.values.InstallPath.value as string; }
|
||||
else if(win32.values.InstallPath.value){ res = win32.values.InstallPath.value as string; }
|
||||
|
||||
let res = '';
|
||||
if(win64.exists && win64?.values?.InstallPath?.value){ res = win64.values.InstallPath.value as string; }
|
||||
else if(win32.exists && win32?.values?.InstallPath?.value){ res = win32.values.InstallPath.value as string; }
|
||||
this.steamPath = res;
|
||||
return this.steamPath;
|
||||
}
|
||||
|
||||
public async getGameFolder(gameId: string, gameFolder?: string): Promise<string>{
|
||||
const steamPath = await this.getSteamPath();
|
||||
|
||||
let libraryFolders: any = path.join(steamPath, 'steamapps', 'libraryfolders.vdf');
|
||||
|
||||
if(!this.utils.pathExist(libraryFolders)){ return null; }
|
||||
libraryFolders = parse(await readFile(libraryFolders, {encoding: 'utf-8'}));
|
||||
|
||||
|
||||
if(!libraryFolders.libraryfolders){ return null; }
|
||||
libraryFolders = libraryFolders.libraryfolders
|
||||
|
||||
|
||||
Reference in New Issue
Block a user