mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
[chore-245] remove some code smells
This commit is contained in:
@@ -5,8 +5,6 @@ import { MSModel, MSModelType } from "shared/models/models/model-saber.model";
|
||||
import { LocalModelsManagerService } from "../services/additional-content/local-models-manager.service";
|
||||
import { IpcService } from "../services/ipc.service";
|
||||
import { BSVersion } from "shared/bs-version.interface";
|
||||
import { BsmLocalMap } from "shared/models/maps/bsm-local-map.interface";
|
||||
import { from } from "rxjs";
|
||||
import { BsmLocalModel } from "shared/models/models/bsm-local-model.interface";
|
||||
import { ModelDownload } from "renderer/services/models-management/models-downloader.service";
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ import { ipcMain, shell } from "electron";
|
||||
import { UtilsService } from "../services/utils.service";
|
||||
import { BSVersionLibService } from "../services/bs-version-lib.service";
|
||||
import { BSVersion } from "shared/bs-version.interface";
|
||||
import { exec } from "child_process";
|
||||
import { IpcRequest } from "shared/models/ipc";
|
||||
import { BSLocalVersionService } from "../services/bs-local-version.service";
|
||||
import { BsmException } from "shared/models/bsm-exception.model";
|
||||
|
||||
@@ -6,8 +6,6 @@ import { NotificationService } from "../services/notification.service";
|
||||
import { SteamService } from "../services/steam.service";
|
||||
import { IpcService } from "../services/ipc.service";
|
||||
import { from } from "rxjs";
|
||||
import { fstat, lstat } from "fs";
|
||||
import { pathExist } from "../helpers/fs.helpers";
|
||||
|
||||
// TODO IMPROVE WINDOW CONTROL BY USING WINDOW SERVICE
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ export class AutoUpdaterService {
|
||||
.checkForUpdates()
|
||||
.then(info => {
|
||||
const needUpdate = (() => {
|
||||
if (!info || !info.updateInfo) {
|
||||
if (!info?.updateInfo) {
|
||||
return false;
|
||||
}
|
||||
return gt(info.updateInfo.version, autoUpdater.currentVersion.version);
|
||||
|
||||
@@ -68,12 +68,14 @@ export class BsModsManagerService {
|
||||
private async getModsInDir(version: BSVersion, modsDir: ModsInstallFolder): Promise<Mod[]> {
|
||||
const bsPath = await this.bsLocalService.getVersionPath(version);
|
||||
const modsPath = path.join(bsPath, modsDir);
|
||||
|
||||
if (!(await pathExist(modsPath))) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const files = await recursiveReadDir(modsPath);
|
||||
const promises = files.map(filePath => {
|
||||
return (async () => {
|
||||
|
||||
const promises = files.map(async filePath => {
|
||||
const ext = path.extname(filePath);
|
||||
|
||||
if (ext !== ".dll" && ext !== ".exe" && ext !== ".manifest") {
|
||||
@@ -100,10 +102,10 @@ export class BsModsManagerService {
|
||||
}
|
||||
}
|
||||
return mod;
|
||||
})();
|
||||
});
|
||||
|
||||
const mods = await Promise.all(promises);
|
||||
return mods.filter(m => !!m);
|
||||
return mods.filter(Boolean);
|
||||
}
|
||||
|
||||
private async getBsipaInstalled(version: BSVersion): Promise<Mod> {
|
||||
|
||||
@@ -84,7 +84,7 @@ export class SteamService {
|
||||
libraryFolders = libraryFolders.libraryfolders;
|
||||
|
||||
for (const libKey in Object.keys(libraryFolders)) {
|
||||
if (!libraryFolders[libKey] || !libraryFolders[libKey].apps) { continue; }
|
||||
if (!libraryFolders?.[libKey]?.apps) { continue; }
|
||||
|
||||
if (libraryFolders[libKey].apps[gameId] != null) {
|
||||
return path.join(libraryFolders[libKey].path, "steamapps", "common", gameFolder);
|
||||
|
||||
Reference in New Issue
Block a user