Skip to content

Commit

Permalink
Merge pull request #81 from foundry-rs/develop
Browse files Browse the repository at this point in the history
hardhat-forge: configurable artifact output (#80)
  • Loading branch information
tynes authored Jul 6, 2022
2 parents 748e467 + 2d33cef commit db59298
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/seven-bees-itch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@foundry-rs/hardhat-forge": patch
---

Add config for writing artifacts to allow conditional writing of artifacts
2 changes: 1 addition & 1 deletion packages/hardhat-forge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"prettier": "prettier \"**/*.{js,md}\"",
"test": "mocha --recursive \"test/**/*.ts\" --exit",
"build": "tsc --build .",
"clean": "rimraf dist"
"clean": "rimraf dist test/fixture-projects/hardhat-project/{artifacts,cache,out}"
},
"files": [
"dist/",
Expand Down
5 changes: 5 additions & 0 deletions packages/hardhat-forge/src/forge/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ registerProjectPathArgs(registerCompilerArgs(task("compile")))
const input = { ...args, ...(hre.config.foundry || {}) };
const buildArgs = await getCheckedArgs(input);
await spawnBuild(buildArgs);

if (hre.config.foundry?.writeArtifacts!) {
(hre as any).artifacts.writeArtifactsSync();
}

if (hre.config.foundry?.runSuper!) {
await runSuper(args);
}
Expand Down
1 change: 1 addition & 0 deletions packages/hardhat-forge/src/forge/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface FoundryHardhatConfig
extends Partial<ForgeEvmArgs>,
Partial<ForgeBuildArgs> {
runSuper?: boolean;
writeArtifacts?: boolean;
}

declare module "hardhat/types/config" {
Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat-forge/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ extendEnvironment((hre: HardhatRuntimeEnvironment) => {
config.build_info
);

artifacts.writeArtifactsSync();
return artifacts;
});
});
Expand All @@ -40,6 +39,7 @@ extendConfig(
// Set default values then merge user defined values
return {
runSuper: false,
writeArtifacts: true,
...userConfig.foundry,
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ const config: HardhatUserConfig = {
solidity: "0.7.3",
defaultNetwork: "hardhat",
foundry: {
viaIr: true
viaIr: true,
writeArtifacts: true,
},
};

Expand Down

0 comments on commit db59298

Please sign in to comment.