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

hardhat-forge: ignore metadata files #101

Merged
merged 2 commits into from Aug 17, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/weak-masks-change.md
@@ -0,0 +1,5 @@
---
"@foundry-rs/hardhat-forge": patch
---

Ignore metadata files when getting contract artifacts
4 changes: 2 additions & 2 deletions packages/hardhat-forge/src/forge/artifacts.ts
Expand Up @@ -165,7 +165,7 @@ export class ForgeArtifacts implements IArtifacts {
const paths = await glob(path.join(this._out, "**/*.json"), {
ignore: path.join(this._buildInfo, "*.json"),
});
return paths.sort();
return paths.filter((p) => !p.endsWith(".metadata.json")).sort();
}

public async getBuildInfoPaths(): Promise<string[]> {
Expand Down Expand Up @@ -218,7 +218,7 @@ export class ForgeArtifacts implements IArtifacts {
const paths = globSync(path.join(this._out, "**/*.json"), {
ignore: path.join(this._buildInfo, "*.json"),
});
return paths.sort();
return paths.filter((p) => !p.endsWith(".metadata.json")).sort();
}

/**
Expand Down
6 changes: 4 additions & 2 deletions packages/hardhat-forge/test/project.test.ts
Expand Up @@ -48,8 +48,10 @@ describe("Integration tests", function () {
it("Should write artifacts to disk", async function () {
const artifacts = await this.hre.artifacts.getArtifactPaths();
const files = await getAllFiles(this.hre.config.paths.artifacts);
// filter out the debug files
const filtered = files.filter((f) => !f.includes(".dbg.json"));
// filter out the debug files and metadata
const filtered = files
.filter((f) => !f.includes(".dbg.json"))
.filter((f) => !f.includes(".metadata.json"));
assert.equal(artifacts.length, filtered.length);

for (const file of filtered) {
Expand Down