From 701b3bf1416b1c2d196cb25161382ccf5f713c72 Mon Sep 17 00:00:00 2001 From: silentrald Date: Sun, 16 Feb 2025 10:39:44 +0800 Subject: [PATCH 1/3] [chore] fixed some lint issues --- src/main/decorators/log.decorator.ts | 4 ++-- .../services/additional-content/maps/song-cache.service.ts | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/decorators/log.decorator.ts b/src/main/decorators/log.decorator.ts index 9c87f932..dd67a4e5 100644 --- a/src/main/decorators/log.decorator.ts +++ b/src/main/decorators/log.decorator.ts @@ -27,10 +27,10 @@ export function Log(options?: LogOptions){ const logOutput = options?.logOutput ?? true; const logArgs = options?.logArgs ?? true; - return (target: unknown, propertyKey: string, descriptor: PropertyDescriptor) => { + return (_target: unknown, propertyKey: string, descriptor: PropertyDescriptor) => { const originalMethod = descriptor.value; - descriptor.value = function(...args: unknown[]) { + descriptor.value = function func(...args: unknown[]) { if (logInput) { logInfo('INPUT', propertyKey, args, logArgs, null); diff --git a/src/main/services/additional-content/maps/song-cache.service.ts b/src/main/services/additional-content/maps/song-cache.service.ts index 751b55d8..26fad375 100644 --- a/src/main/services/additional-content/maps/song-cache.service.ts +++ b/src/main/services/additional-content/maps/song-cache.service.ts @@ -19,7 +19,6 @@ export class SongCacheService { private readonly mapsInfoCache: JsonCache; private constructor(){ - console.log(this.MAPS_INFO_CACHE_PATH); this.mapsInfoCache = new JsonCache(this.MAPS_INFO_CACHE_PATH); } From a7d00f22c5c04f5ca6384423632e2da56283c091 Mon Sep 17 00:00:00 2001 From: Zagrios <40181755+Zagrios@users.noreply.github.com> Date: Wed, 19 Feb 2025 19:06:23 +0100 Subject: [PATCH 2/3] Convert throwed object to CustomError --- src/main/helpers/fs.helpers.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/helpers/fs.helpers.ts b/src/main/helpers/fs.helpers.ts index 58f8f233..d10583d2 100644 --- a/src/main/helpers/fs.helpers.ts +++ b/src/main/helpers/fs.helpers.ts @@ -3,7 +3,6 @@ import { access, mkdir, readdir, lstat, readlink } from "fs/promises"; import path from "path"; import { Observable, concatMap, from } from "rxjs"; import log from "electron-log"; -import { BsmException } from "shared/models/bsm-exception.model"; import crypto from "crypto"; import { execSync } from "child_process"; import { tryit } from "../../shared/helpers/error.helpers"; @@ -180,7 +179,7 @@ export function isSubdirectory(parent: string, child: string): boolean { export async function copyDirectoryWithJunctions(src: string, dest: string, options?: CopyOptions): Promise { if (isSubdirectory(src, dest)) { - throw { message: `Cannot copy directory '${src}' into itself '${dest}'.`, code: "COPY_TO_SUBPATH" } as BsmException; + throw new CustomError(`Cannot copy directory '${src}' into itself '${dest}'.`, "COPY_TO_SUBPATH"); } await ensureDir(dest); From b525cac25039ab8729bb51af663c5e7b291e1e23 Mon Sep 17 00:00:00 2001 From: silentrald Date: Fri, 21 Feb 2025 23:27:13 +0800 Subject: [PATCH 3/3] [chore] removed log decorators --- src/main/decorators/log.decorator.ts | 67 ---------------------------- 1 file changed, 67 deletions(-) delete mode 100644 src/main/decorators/log.decorator.ts diff --git a/src/main/decorators/log.decorator.ts b/src/main/decorators/log.decorator.ts deleted file mode 100644 index dd67a4e5..00000000 --- a/src/main/decorators/log.decorator.ts +++ /dev/null @@ -1,67 +0,0 @@ -import log from "electron-log"; -import { isPromise } from "../../shared/helpers/promise.helpers"; -import { tryit } from "../../shared/helpers/error.helpers"; - -type LogOptions = { - logInput?: boolean; - logOutput?: boolean; - logArgs?: boolean; -}; - -const stringifyArgs = (args: unknown[]) => { - return args?.map(a => JSON.stringify(a)).join(', '); -}; - -const logInfo = (message: string, propertyKey: string, args: unknown[], logArgs: boolean, result: unknown) => { - log.info(`[${message}] ${propertyKey}(${logArgs ? stringifyArgs(args) : ''})`, result); -}; - -const logError = (propertyKey: string, args: unknown[], logArgs: boolean, error: unknown) => { - log.error(`[ERROR] ${propertyKey}(${logArgs ? stringifyArgs(args) : ''})`, error); - throw error; -}; - -export function Log(options?: LogOptions){ - - const logInput = options?.logInput ?? false; - const logOutput = options?.logOutput ?? true; - const logArgs = options?.logArgs ?? true; - - return (_target: unknown, propertyKey: string, descriptor: PropertyDescriptor) => { - const originalMethod = descriptor.value; - - descriptor.value = function func(...args: unknown[]) { - - if (logInput) { - logInfo('INPUT', propertyKey, args, logArgs, null); - } - - const outcome = tryit(() => originalMethod.apply(this, args)); - - if (isPromise(outcome)) { - return outcome.then(({ result, error }) => { - - if (error) { - logError(propertyKey, args, logArgs, error); - } - if (logOutput) { - logInfo('OUTPUT', propertyKey, args, logArgs, result); - } - return result; - }); - } - - const { result, error } = outcome; - - if (error) { - logError(propertyKey, args, logArgs, error); - } - - if (logOutput) { - logInfo('OUTPUT', propertyKey, args, logArgs, result); - } - - return result; - }; - }; -}