From 28030b71206c32bc144ae851b77884af0aca52b8 Mon Sep 17 00:00:00 2001 From: BellCube Dev <33764825+BellCubeDev@users.noreply.github.com> Date: Tue, 19 Mar 2024 22:31:48 -0400 Subject: [PATCH] Some Bug Fixes Related To Document Associations --- package.json | 2 +- src/definitions/lib/FlagInstance.ts | 3 ++- src/definitions/module/Install.ts | 2 +- src/definitions/module/Option.ts | 4 +++- src/definitions/module/dependencies/DependenciesGroup.ts | 2 +- tsconfig.json | 3 +-- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 5db41a3..625ad58 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "type": "module", "name": "fomod", "description": "A library for creating, parsing, editing, and validating XML-based Fomod installers, widely popularized in the Bethesda modding scene", - "version": "0.2.3", + "version": "0.2.4", "main": "dist/index.js", "repository": "https://github.com/BellCubeDev/fomod-js/", "bugs": { diff --git a/src/definitions/lib/FlagInstance.ts b/src/definitions/lib/FlagInstance.ts index 575394f..e3f989d 100644 --- a/src/definitions/lib/FlagInstance.ts +++ b/src/definitions/lib/FlagInstance.ts @@ -75,6 +75,7 @@ export class FlagInstance extends XmlRepresentation } associateWithDocument(document: Document) { - this.attachDocument(document); + if (!this.documents.has(document)) this.attachDocument(document); } decommission(currentDocument?: Document) { diff --git a/src/definitions/module/Option.ts b/src/definitions/module/Option.ts index 6889e12..41c69f3 100644 --- a/src/definitions/module/Option.ts +++ b/src/definitions/module/Option.ts @@ -129,7 +129,9 @@ export class Option extends XmlRepresentation const name = baseName + `--${suffix}`; if (!existingFlagNames.has(name)) { - return new FlagSetter(new FlagInstance(name, config.optionSelectedValue ?? DefaultFomodDocumentConfig.optionSelectedValue, true)); + const setter = new FlagSetter(new FlagInstance(name, config.optionSelectedValue ?? DefaultFomodDocumentConfig.optionSelectedValue, true)); + setter.associateWithDocument(document); + return setter; } return tryNextName(suffix + 1n); diff --git a/src/definitions/module/dependencies/DependenciesGroup.ts b/src/definitions/module/dependencies/DependenciesGroup.ts index 754a011..9150955 100644 --- a/src/definitions/module/dependencies/DependenciesGroup.ts +++ b/src/definitions/module/dependencies/DependenciesGroup.ts @@ -38,7 +38,7 @@ export class DependenciesGroup d.associateWithDocument(document)); + this.dependencies.forEach(d => d.associateWithDocument?.(document)); } override asElement(document: Document, config: FomodDocumentConfig = {}, knownOptions: Option[] = []): Element { diff --git a/tsconfig.json b/tsconfig.json index 72801c9..4156223 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,12 +17,11 @@ // Output Options "alwaysStrict": true, - "removeComments": true, + //"removeComments": true, -- removed JSDoc comments "importsNotUsedAsValues": "remove", "declarationMap": true, "sourceMap": true, - "sourceRoot": "https://raw.githubusercontent.com/BellCubeDev/fomod-js/main/", // Type Checking: Maximum Carnage "strict": true,