Skip to content

Commit beca2be

Browse files
committed
Exclude artifacts/package.json from artifacts in getArtifactPaths
1 parent efbcce6 commit beca2be

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

packages/hardhat-core/src/internal/artifacts.ts

+13-16
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,8 @@ export class Artifacts implements IArtifacts {
154154
return cached;
155155
}
156156

157-
const buildInfosDir = path.join(this._artifactsPath, BUILD_INFO_DIR_NAME);
158-
159-
const paths = await getAllFilesMatching(
160-
this._artifactsPath,
161-
(f) =>
162-
f.endsWith(".json") &&
163-
!f.startsWith(buildInfosDir) &&
164-
!f.endsWith(".dbg.json")
157+
const paths = await getAllFilesMatching(this._artifactsPath, (f) =>
158+
this._isArtifactPath(f)
165159
);
166160

167161
const result = paths.sort();
@@ -563,14 +557,8 @@ export class Artifacts implements IArtifacts {
563557
return cached;
564558
}
565559

566-
const buildInfosDir = path.join(this._artifactsPath, BUILD_INFO_DIR_NAME);
567-
568-
const paths = getAllFilesMatchingSync(
569-
this._artifactsPath,
570-
(f) =>
571-
f.endsWith(".json") &&
572-
!f.startsWith(buildInfosDir) &&
573-
!f.endsWith(".dbg.json")
560+
const paths = getAllFilesMatchingSync(this._artifactsPath, (f) =>
561+
this._isArtifactPath(f)
574562
);
575563

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

935923
return undefined;
936924
}
925+
926+
private _isArtifactPath(file: string) {
927+
return (
928+
file.endsWith(".json") &&
929+
file !== path.join(this._artifactsPath, "package.json") &&
930+
!file.startsWith(path.join(this._artifactsPath, BUILD_INFO_DIR_NAME)) &&
931+
!file.endsWith(".dbg.json")
932+
);
933+
}
937934
}
938935

939936
/**

0 commit comments

Comments
 (0)