Skip to content

Commit

Permalink
Exclude artifacts/package.json from artifacts in getArtifactPaths
Browse files Browse the repository at this point in the history
  • Loading branch information
schaable committed Dec 5, 2023
1 parent efbcce6 commit beca2be
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions packages/hardhat-core/src/internal/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,8 @@ export class Artifacts implements IArtifacts {
return cached;
}

const buildInfosDir = path.join(this._artifactsPath, BUILD_INFO_DIR_NAME);

const paths = await getAllFilesMatching(
this._artifactsPath,
(f) =>
f.endsWith(".json") &&
!f.startsWith(buildInfosDir) &&
!f.endsWith(".dbg.json")
const paths = await getAllFilesMatching(this._artifactsPath, (f) =>
this._isArtifactPath(f)
);

const result = paths.sort();
Expand Down Expand Up @@ -563,14 +557,8 @@ export class Artifacts implements IArtifacts {
return cached;
}

const buildInfosDir = path.join(this._artifactsPath, BUILD_INFO_DIR_NAME);

const paths = getAllFilesMatchingSync(
this._artifactsPath,
(f) =>
f.endsWith(".json") &&
!f.startsWith(buildInfosDir) &&
!f.endsWith(".dbg.json")
const paths = getAllFilesMatchingSync(this._artifactsPath, (f) =>
this._isArtifactPath(f)
);

const result = paths.sort();
Expand Down Expand Up @@ -934,6 +922,15 @@ Please replace "${contractName}" for the correct contract name wherever you are

return undefined;
}

private _isArtifactPath(file: string) {
return (
file.endsWith(".json") &&
file !== path.join(this._artifactsPath, "package.json") &&
!file.startsWith(path.join(this._artifactsPath, BUILD_INFO_DIR_NAME)) &&
!file.endsWith(".dbg.json")
);
}
}

/**
Expand Down

0 comments on commit beca2be

Please sign in to comment.