diff --git a/src/utils/io/file-info.ts b/src/utils/io/file-info.ts index 4608555..c8b23d8 100644 --- a/src/utils/io/file-info.ts +++ b/src/utils/io/file-info.ts @@ -134,6 +134,15 @@ export class FileInfo { toString() { return this._path; } + + /** + * Returns the file path. + * + * @returns The file path. + */ + toJSON() { + return this._path; + } } /** diff --git a/tests/unit/utils/io/file-info.spec.ts b/tests/unit/utils/io/file-info.spec.ts index ab71814..3318a41 100644 --- a/tests/unit/utils/io/file-info.spec.ts +++ b/tests/unit/utils/io/file-info.spec.ts @@ -166,6 +166,12 @@ describe("FileInfo", () => { expect(info.toString()).toBe("path/to/test.txt"); }); }); + + test("should be converted to JSON as a file path string", () => { + const info = new FileInfo("path/to/test.txt"); + + expect(JSON.stringify(info)).toBe("\"path/to/test.txt\""); + }); }); describe("fileEquals", () => {