From e539b1fa7621c48585e045fba25171d96bcf40ae Mon Sep 17 00:00:00 2001 From: Mythic Date: Fri, 9 Feb 2024 04:54:47 +0200 Subject: [PATCH] A handful of minor improvements + missing await --- src/installers/InstallRuleInstaller.ts | 23 +++++++++++-------- src/installers/ShimloaderInstaller.ts | 6 ++--- .../ConflictManagementProviderImpl.ts | 4 ++-- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/installers/InstallRuleInstaller.ts b/src/installers/InstallRuleInstaller.ts index 623ba40a..83795822 100644 --- a/src/installers/InstallRuleInstaller.ts +++ b/src/installers/InstallRuleInstaller.ts @@ -115,14 +115,19 @@ async function installSubDirNoFlatten(profile: Profile, rule: ManagedRule, insta } } -async function installSubDirTracked(profile: Profile, rule: ManagedRule, installSources: string[], mod: ManifestV2) { +async function installSubDirTracked( + profile: Profile, + rule: ManagedRule, + installSources: string[], + mod: ManifestV2 +) { const fs = FsProvider.instance; const subDir = path.join(profile.getPathOfProfile(), rule.route, mod.getName()); await FileUtils.ensureDirectory(subDir); const relocations = new Map(); - let makeProfilePath = (input: string): string => { + const makeProfilePath = (input: string): string => { const match = installSources.find((x) => input.startsWith(x)); if (match === undefined) { return input; @@ -145,16 +150,16 @@ async function installSubDirTracked(profile: Profile, rule: ManagedRule, install await fs.mkdirs(destDir); } - fs.copyFile(source, dest); - + await fs.copyFile(source, dest); + const profileRel = dest.replace(profile.getPathOfProfile(), "").substring(1); relocations.set(source, profileRel); - - continue; + } else { + const contents = (await fs.readdir(source)).map( + (x) => path.join(source as string, x) + ); + sources.push(...contents); } - - const contents = (await fs.readdir(source)).map((x) => path.join(source as string, x)); - sources.push(...contents); } await addToStateFile(mod, relocations, profile); diff --git a/src/installers/ShimloaderInstaller.ts b/src/installers/ShimloaderInstaller.ts index 0a73ecd0..86c049b7 100644 --- a/src/installers/ShimloaderInstaller.ts +++ b/src/installers/ShimloaderInstaller.ts @@ -63,7 +63,7 @@ export class ShimloaderPluginInstaller extends PackageInstaller { relativeFileExclusions: ["manifest.json", "README.md", "icon.png", "LICENCE"], rules: [ { - route: path.join("shimloader/mod"), + route: path.join("shimloader", "mod"), defaultFileExtensions: [".lua"], trackingMethod: "SUBDIR_TRACKED", subRoutes: [ @@ -76,13 +76,13 @@ export class ShimloaderPluginInstaller extends PackageInstaller { ] }, { - route: path.join("shimloader/pak"), + route: path.join("shimloader", "pak"), defaultFileExtensions: [".pak"], trackingMethod: "SUBDIR_TRACKED", subRoutes: [], }, { - route: path.join("shimloader/cfg"), + route: path.join("shimloader", "cfg"), defaultFileExtensions: [".cfg"], trackingMethod: "NONE", subRoutes: [], diff --git a/src/r2mm/installing/ConflictManagementProviderImpl.ts b/src/r2mm/installing/ConflictManagementProviderImpl.ts index 2edd3dc0..d4e7337f 100644 --- a/src/r2mm/installing/ConflictManagementProviderImpl.ts +++ b/src/r2mm/installing/ConflictManagementProviderImpl.ts @@ -55,7 +55,7 @@ export default class ConflictManagementProviderImpl extends ConflictManagementPr const modState: ModFileTracker = yaml.parse(stateFileContents); modState.files.forEach(([key, value]) => { // HACK: Never reset UE4SS-settings.ini, ever. Seriously. It should always be enabled. - if (value.toLocaleLowerCase() == "ue4ss-settings.ini") { + if (value.toLowerCase() == "ue4ss-settings.ini") { overallState.set(value, mod.getName()); } else if (mod.isEnabled()) { overallState.set(value, mod.getName()); @@ -85,7 +85,7 @@ export default class ConflictManagementProviderImpl extends ConflictManagementPr await FileUtils.ensureDirectory(path.dirname(path.join(profile.getPathOfProfile(), file))); // HACK: Check if UE4SS-settings.ini exists and, if it doesn't, add it. If it does exist, DONT TOUCH. - if (file.toLocaleLowerCase() == "ue4ss-settings.ini") { + if (file.toLowerCase() == "ue4ss-settings.ini") { if (!await FsProvider.instance.exists(path.join(profile.getPathOfProfile(), file))) { await FsProvider.instance.copyFile(key, path.join(profile.getPathOfProfile(), file)); }