Skip to content

Commit

Permalink
A handful of minor improvements + missing await
Browse files Browse the repository at this point in the history
  • Loading branch information
MythicManiac committed Feb 9, 2024
1 parent da2e2ba commit e539b1f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
23 changes: 14 additions & 9 deletions src/installers/InstallRuleInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string>();

let makeProfilePath = (input: string): string => {
const makeProfilePath = (input: string): string => {
const match = installSources.find((x) => input.startsWith(x));
if (match === undefined) {
return input;
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/installers/ShimloaderInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -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: [],
Expand Down
4 changes: 2 additions & 2 deletions src/r2mm/installing/ConflictManagementProviderImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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));
}
Expand Down

0 comments on commit e539b1f

Please sign in to comment.