Skip to content

Commit

Permalink
feat: refresh a project (#1128)
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Aug 13, 2024
1 parent 6124ca6 commit 56a93bb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/sfProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ export class SfProjectJson extends ConfigFile<ConfigFile.Options, ProjectJson> {
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();
Expand Down Expand Up @@ -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.
*
Expand Down
3 changes: 1 addition & 2 deletions src/testSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 56a93bb

Please sign in to comment.