fix: handle when there is no overrides in the modpack
This commit is contained in:
parent
4d7eb93b88
commit
23639e867e
2 changed files with 43 additions and 19 deletions
|
|
@ -132,7 +132,7 @@ export async function getOverridesChanges(
|
||||||
overridesList.find(
|
overridesList.find(
|
||||||
(a) =>
|
(a) =>
|
||||||
path.relative(overridesPath, path.join(a.parentPath, a.name)) ===
|
path.relative(overridesPath, path.join(a.parentPath, a.name)) ===
|
||||||
relativePath,
|
relativePath,
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
// overwrite as it may be a different file
|
// overwrite as it may be a different file
|
||||||
|
|
@ -163,10 +163,10 @@ export async function getOverridesChanges(
|
||||||
!oldOverridesList.find(
|
!oldOverridesList.find(
|
||||||
(oldFile) =>
|
(oldFile) =>
|
||||||
relativePath ===
|
relativePath ===
|
||||||
path.relative(
|
path.relative(
|
||||||
oldOverridesPath,
|
oldOverridesPath,
|
||||||
path.join(oldFile.parentPath, oldFile.name),
|
path.join(oldFile.parentPath, oldFile.name),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
// new file
|
// new file
|
||||||
|
|
@ -187,10 +187,11 @@ export async function getOverridesChanges(
|
||||||
addedDirs.push(
|
addedDirs.push(
|
||||||
path.relative(overridesPath, path.join(file.parentPath, file.name)),
|
path.relative(overridesPath, path.join(file.parentPath, file.name)),
|
||||||
);
|
);
|
||||||
} else
|
} else {
|
||||||
addedOverrides.push(
|
addedOverrides.push(
|
||||||
path.relative(overridesPath, path.join(file.parentPath, file.name)),
|
path.relative(overridesPath, path.join(file.parentPath, file.name)),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
@ -224,10 +225,24 @@ export async function generatePackChanges(
|
||||||
manifest,
|
manifest,
|
||||||
oldManifest,
|
oldManifest,
|
||||||
);
|
);
|
||||||
const overridesChanges = await getOverridesChanges(
|
|
||||||
instanceFolder,
|
let overridesChanges: Awaited<ReturnType<typeof getOverridesChanges>> = {
|
||||||
tempFolder,
|
addedDirs: [],
|
||||||
);
|
addedOverrides: [],
|
||||||
|
removedDirs: [],
|
||||||
|
removedOverrides: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
if (
|
||||||
|
await exists(
|
||||||
|
path.join(tempFolder, "pack", "overrides"),
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
overridesChanges = await getOverridesChanges(
|
||||||
|
instanceFolder,
|
||||||
|
tempFolder,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return { modrinthChanges, overridesChanges };
|
return { modrinthChanges, overridesChanges };
|
||||||
}
|
}
|
||||||
|
|
@ -241,7 +256,7 @@ export async function ModrinthDownloader(
|
||||||
concurrency: 5,
|
concurrency: 5,
|
||||||
},
|
},
|
||||||
updateSize: true,
|
updateSize: true,
|
||||||
overwrite: true
|
overwrite: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
modrinthDownloader.on("completed", () => {
|
modrinthDownloader.on("completed", () => {
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import { EventEmitter } from "events";
|
import { EventEmitter } from "events";
|
||||||
import {
|
import {
|
||||||
Config,
|
Config,
|
||||||
|
FinalConfig,
|
||||||
InstanceEvents,
|
InstanceEvents,
|
||||||
logger,
|
logger,
|
||||||
Version,
|
|
||||||
FinalConfig,
|
|
||||||
ModloaderConfig,
|
ModloaderConfig,
|
||||||
|
Version,
|
||||||
} from "../utils/types";
|
} from "../utils/types";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import {
|
import {
|
||||||
|
|
@ -53,8 +53,8 @@ export function defineConfig(logger: logger, config: Config) {
|
||||||
instance: config.paths.instance,
|
instance: config.paths.instance,
|
||||||
versions: config.paths.versions ?? path.join(config.paths.root, "versions"),
|
versions: config.paths.versions ?? path.join(config.paths.root, "versions"),
|
||||||
assets: config.paths.assets ?? path.join(config.paths.root, "assets"),
|
assets: config.paths.assets ?? path.join(config.paths.root, "assets"),
|
||||||
libraries:
|
libraries: config.paths.libraries ??
|
||||||
config.paths.libraries ?? path.join(config.paths.root, "libraries"),
|
path.join(config.paths.root, "libraries"),
|
||||||
};
|
};
|
||||||
|
|
||||||
config.args = {
|
config.args = {
|
||||||
|
|
@ -267,15 +267,24 @@ export class Instance extends EventEmitter<InstanceEvents> {
|
||||||
|
|
||||||
// Delete before downloading
|
// Delete before downloading
|
||||||
|
|
||||||
await ProjectsDeleter(modrinthChanges.removedProject, (...args) => this.emit(...args));
|
await ProjectsDeleter(
|
||||||
|
modrinthChanges.removedProject,
|
||||||
|
(...args) => this.emit(...args),
|
||||||
|
);
|
||||||
|
|
||||||
await ModrinthDownloader(modrinthChanges.addedProjects, (...args) => this.emit(...args));
|
await ModrinthDownloader(
|
||||||
|
modrinthChanges.addedProjects,
|
||||||
|
(...args) => this.emit(...args),
|
||||||
|
);
|
||||||
|
|
||||||
await OverridesDeleter(overridesChanges, (...args) => this.emit(...args));
|
await OverridesDeleter(
|
||||||
|
overridesChanges,
|
||||||
|
(...args) => this.emit(...args),
|
||||||
|
);
|
||||||
|
|
||||||
await OverridesCopier(
|
await OverridesCopier(
|
||||||
overridesChanges.addedOverrides,
|
overridesChanges.addedOverrides,
|
||||||
path.join(this.config.modrinth.tempFolder, 'pack', 'overrides'),
|
path.join(this.config.modrinth.tempFolder, "pack", "overrides"),
|
||||||
this.config.paths.instance,
|
this.config.paths.instance,
|
||||||
(...args) => this.emit(...args),
|
(...args) => this.emit(...args),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue