From 536690dc5577c7e444a3a1adcccb767708795071 Mon Sep 17 00:00:00 2001 From: MathieuG-P <40181755+Zagrios@users.noreply.github.com> Date: Sat, 27 Jan 2024 13:46:44 +0100 Subject: [PATCH] [bugfix-411] dynamically import regedit-rs depending on the os --- src/main/services/liv/liv.service.ts | 3 ++- src/main/services/oculus.service.ts | 4 +++- src/main/services/steam.service.ts | 5 ++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/services/liv/liv.service.ts b/src/main/services/liv/liv.service.ts index 38b488e14..b94038ece 100644 --- a/src/main/services/liv/liv.service.ts +++ b/src/main/services/liv/liv.service.ts @@ -1,8 +1,9 @@ import { execOnOs } from "../../helpers/env.helpers"; -import { list, createKey, putValue, deleteKey, RegSzValue } from "regedit-rs"; import path from "path"; import { Log } from "../../decorators/log.decorator"; +const { list, createKey, putValue, deleteKey, RegSzValue } = (execOnOs({ win32: () => require("regedit-rs") }, true) ?? {}) as typeof import("regedit-rs"); + export class LivService { private static instance: LivService; diff --git a/src/main/services/oculus.service.ts b/src/main/services/oculus.service.ts index f465fd0e2..2119a02f0 100644 --- a/src/main/services/oculus.service.ts +++ b/src/main/services/oculus.service.ts @@ -1,4 +1,3 @@ -import { list } from "regedit-rs"; import path from "path"; import { pathExist, resolveGUIDPath } from "../helpers/fs.helpers"; import log from "electron-log"; @@ -7,6 +6,9 @@ import { tryit } from "../../shared/helpers/error.helpers"; import { shell } from "electron"; import { taskRunning } from "../helpers/os.helpers"; import { sToMs } from "../../shared/helpers/time.helpers"; +import { execOnOs } from "../helpers/env.helpers"; + +const { list } = (execOnOs({ win32: () => require("regedit-rs") }, true) ?? {}) as typeof import("regedit-rs"); export class OculusService { private static instance: OculusService; diff --git a/src/main/services/steam.service.ts b/src/main/services/steam.service.ts index 5583169db..9d348a8a4 100644 --- a/src/main/services/steam.service.ts +++ b/src/main/services/steam.service.ts @@ -1,4 +1,4 @@ -import { list, RegDwordValue } from "regedit-rs" +import { RegDwordValue } from "regedit-rs" import path from "path"; import { parse } from "@node-steam/vdf"; import { readFile } from "fs/promises"; @@ -7,6 +7,9 @@ import log from "electron-log"; import { app, shell } from "electron"; import { getProcessPid, taskRunning } from "../helpers/os.helpers"; import { isElevated } from "query-process"; +import { execOnOs } from "../helpers/env.helpers"; + +const { list } = (execOnOs({ win32: () => require("regedit-rs") }, true) ?? {}) as typeof import("regedit-rs"); export class SteamService {