Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: refresh a project #1128

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading