Skip to content

Commit

Permalink
Merge pull request #4951 from theethernaut/parse-before-extendenv
Browse files Browse the repository at this point in the history
Create env before args are parsed
  • Loading branch information
alcuadrado authored Mar 15, 2024
2 parents 739553e + 7876104 commit fa1d2b1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .changeset/dull-pigs-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"hardhat": patch
---

Initialize the Hardhat Runtime Environment before passing the command line arguments.
26 changes: 13 additions & 13 deletions packages/hardhat-core/src/internal/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,19 @@ async function main() {
const taskDefinitions = ctx.tasksDSL.getTaskDefinitions();
const scopesDefinitions = ctx.tasksDSL.getScopesDefinitions();

const env = new Environment(
resolvedConfig,
hardhatArguments,
taskDefinitions,
scopesDefinitions,
envExtenders,
ctx.experimentalHardhatNetworkMessageTraceHooks,
userConfig,
providerExtenders
);

ctx.setHardhatRuntimeEnvironment(env);

// eslint-disable-next-line prefer-const
let { scopeName, taskName, unparsedCLAs } =
argumentsParser.parseScopeAndTaskNames(
Expand Down Expand Up @@ -304,19 +317,6 @@ async function main() {
);
}

const env = new Environment(
resolvedConfig,
hardhatArguments,
taskDefinitions,
scopesDefinitions,
envExtenders,
ctx.experimentalHardhatNetworkMessageTraceHooks,
userConfig,
providerExtenders
);

ctx.setHardhatRuntimeEnvironment(env);

try {
const timestampBeforeRun = new Date().getTime();

Expand Down

0 comments on commit fa1d2b1

Please sign in to comment.