Skip to content

Commit fa1d2b1

Browse files
authored
Merge pull request #4951 from theethernaut/parse-before-extendenv
Create env before args are parsed
2 parents 739553e + 7876104 commit fa1d2b1

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

.changeset/dull-pigs-pay.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"hardhat": patch
3+
---
4+
5+
Initialize the Hardhat Runtime Environment before passing the command line arguments.

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

+13-13
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,19 @@ async function main() {
228228
const taskDefinitions = ctx.tasksDSL.getTaskDefinitions();
229229
const scopesDefinitions = ctx.tasksDSL.getScopesDefinitions();
230230

231+
const env = new Environment(
232+
resolvedConfig,
233+
hardhatArguments,
234+
taskDefinitions,
235+
scopesDefinitions,
236+
envExtenders,
237+
ctx.experimentalHardhatNetworkMessageTraceHooks,
238+
userConfig,
239+
providerExtenders
240+
);
241+
242+
ctx.setHardhatRuntimeEnvironment(env);
243+
231244
// eslint-disable-next-line prefer-const
232245
let { scopeName, taskName, unparsedCLAs } =
233246
argumentsParser.parseScopeAndTaskNames(
@@ -304,19 +317,6 @@ async function main() {
304317
);
305318
}
306319

307-
const env = new Environment(
308-
resolvedConfig,
309-
hardhatArguments,
310-
taskDefinitions,
311-
scopesDefinitions,
312-
envExtenders,
313-
ctx.experimentalHardhatNetworkMessageTraceHooks,
314-
userConfig,
315-
providerExtenders
316-
);
317-
318-
ctx.setHardhatRuntimeEnvironment(env);
319-
320320
try {
321321
const timestampBeforeRun = new Date().getTime();
322322

0 commit comments

Comments
 (0)