diff --git a/src/core/modrinth.ts b/src/core/modrinth.ts index c699e38..fbc6e1d 100644 --- a/src/core/modrinth.ts +++ b/src/core/modrinth.ts @@ -132,7 +132,7 @@ export async function getOverridesChanges( overridesList.find( (a) => path.relative(overridesPath, path.join(a.parentPath, a.name)) === - relativePath, + relativePath, ) ) { // overwrite as it may be a different file @@ -163,10 +163,10 @@ export async function getOverridesChanges( !oldOverridesList.find( (oldFile) => relativePath === - path.relative( - oldOverridesPath, - path.join(oldFile.parentPath, oldFile.name), - ), + path.relative( + oldOverridesPath, + path.join(oldFile.parentPath, oldFile.name), + ), ) ) { // new file @@ -187,10 +187,11 @@ export async function getOverridesChanges( addedDirs.push( path.relative(overridesPath, path.join(file.parentPath, file.name)), ); - } else + } else { addedOverrides.push( path.relative(overridesPath, path.join(file.parentPath, file.name)), ); + } } return { @@ -224,10 +225,24 @@ export async function generatePackChanges( manifest, oldManifest, ); - const overridesChanges = await getOverridesChanges( - instanceFolder, - tempFolder, - ); + + let overridesChanges: Awaited> = { + addedDirs: [], + addedOverrides: [], + removedDirs: [], + removedOverrides: [], + }; + + if ( + await exists( + path.join(tempFolder, "pack", "overrides"), + ) + ) { + overridesChanges = await getOverridesChanges( + instanceFolder, + tempFolder, + ); + } return { modrinthChanges, overridesChanges }; } @@ -241,7 +256,7 @@ export async function ModrinthDownloader( concurrency: 5, }, updateSize: true, - overwrite: true + overwrite: true, }); modrinthDownloader.on("completed", () => { diff --git a/src/launcher/instance.ts b/src/launcher/instance.ts index 751ab46..08d9a98 100644 --- a/src/launcher/instance.ts +++ b/src/launcher/instance.ts @@ -1,11 +1,11 @@ import { EventEmitter } from "events"; import { Config, + FinalConfig, InstanceEvents, logger, - Version, - FinalConfig, ModloaderConfig, + Version, } from "../utils/types"; import path from "node:path"; import { @@ -53,8 +53,8 @@ export function defineConfig(logger: logger, config: Config) { instance: config.paths.instance, versions: config.paths.versions ?? path.join(config.paths.root, "versions"), assets: config.paths.assets ?? path.join(config.paths.root, "assets"), - libraries: - config.paths.libraries ?? path.join(config.paths.root, "libraries"), + libraries: config.paths.libraries ?? + path.join(config.paths.root, "libraries"), }; config.args = { @@ -267,15 +267,24 @@ export class Instance extends EventEmitter { // 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( overridesChanges.addedOverrides, - path.join(this.config.modrinth.tempFolder, 'pack', 'overrides'), + path.join(this.config.modrinth.tempFolder, "pack", "overrides"), this.config.paths.instance, (...args) => this.emit(...args), );