From 15781bb038ef626f0e3df1895bd1aace041a0b3f Mon Sep 17 00:00:00 2001 From: Cooldude2606 <25043174+Cooldude2606@users.noreply.github.com> Date: Fri, 10 Jul 2026 22:00:42 +0100 Subject: [PATCH] Setting filepath on config makes it dirty --- packages/lib/src/config/classes.ts | 11 ++++++++++- test/lib/config/classes.js | 22 ++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/packages/lib/src/config/classes.ts b/packages/lib/src/config/classes.ts index 574237c1..d982f174 100644 --- a/packages/lib/src/config/classes.ts +++ b/packages/lib/src/config/classes.ts @@ -251,7 +251,7 @@ export class Config< constructor( public location: ConfigLocation, fields?: Static, - public filepath?: string, + private _filepath?: string, ) { if (typeof location !== "string") { throw new Error("location must be a string"); @@ -273,6 +273,15 @@ export class Config< } } + get filepath() { + return this._filepath; + } + + set filepath(filepath: string | undefined) { + this.dirty = true; + this._filepath = filepath; + } + /** A staging version of the config with changes tracked, invalided by revertStaging */ private _staging?: { config: Config, changes: Set}; diff --git a/test/lib/config/classes.js b/test/lib/config/classes.js index d4468d1d..40e8cbb4 100644 --- a/test/lib/config/classes.js +++ b/test/lib/config/classes.js @@ -176,6 +176,28 @@ describe("lib/config/classes", function() { }); }); + describe("get filepath", function() { + it("returns the current filepath for the config", function() { + const testInstance = new TestConfig("local", undefined, "foo/bar"); + assert.equal(testInstance.filepath, "foo/bar"); + }); + }); + + describe("set filepath", function() { + it("sets the current filepath for the config", function() { + const testInstance = new TestConfig("local"); + assert.equal(testInstance.filepath, undefined); + testInstance.filepath = "foo/bar"; + assert.equal(testInstance.filepath, "foo/bar"); + }); + it("sets the dirty flag", function() { + const testInstance = new TestConfig("local"); + assert.equal(testInstance.dirty, false); + testInstance.filepath = "foo/bar"; + assert.equal(testInstance.dirty, true); + }); + }); + describe(".toJSON()", function() { it("should serialize a basic config", function() { const testInstance = new TestConfig("local");