diff --git a/src/sfProject.ts b/src/sfProject.ts index 5980a2d37..c89c22c18 100644 --- a/src/sfProject.ts +++ b/src/sfProject.ts @@ -84,6 +84,12 @@ export class SfProjectJson extends ConfigFile { return contents; } + /** force a reread of the project contents if you know they may have been modified */ + public refreshSync(): SfProjectJson { + super.readSync(false, true); + return this; + } + public readSync(): ProjectJson { const contents = super.readSync(); this.validateKeys(); @@ -369,6 +375,14 @@ export class SfProject { */ protected constructor(private path: string) {} + /** + * Clear the cache to force reading from disk. + * + * *NOTE: Only call this method if you must and you know what you are doing.* + */ + public static clearInstances(): void { + SfProject.instances.clear(); + } /** * Get a Project from a given path or from the working directory. * diff --git a/src/testSetup.ts b/src/testSetup.ts index b126782c6..e664994c6 100644 --- a/src/testSetup.ts +++ b/src/testSetup.ts @@ -666,8 +666,7 @@ export const restoreContext = (testContext: TestContext): void => { testContext.configStubs = {}; // Give each test run a clean StateAggregator StateAggregator.clearInstance(); - // @ts-expect-error accessing a private property - SfProject.instances.clear(); + SfProject.clearInstances(); // Allow each test to have their own config aggregator // @ts-ignore clear for testing. delete ConfigAggregator.instance;