1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.resetHardhatContext = void 0;
|
4 | const context_1 = require("./context");
|
5 |
|
6 |
|
7 | function resetHardhatContext() {
|
8 | if (context_1.HardhatContext.isCreated()) {
|
9 | const ctx = context_1.HardhatContext.getHardhatContext();
|
10 | if (ctx.environment !== undefined) {
|
11 | const globalAsAny = global;
|
12 | for (const key of Object.keys(ctx.environment)) {
|
13 | globalAsAny.hre = undefined;
|
14 | globalAsAny[key] = undefined;
|
15 | }
|
16 | }
|
17 | const filesLoadedDuringConfig = ctx.getFilesLoadedDuringConfig();
|
18 | filesLoadedDuringConfig.forEach(unloadModule);
|
19 | context_1.HardhatContext.deleteHardhatContext();
|
20 | }
|
21 |
|
22 | unloadModule("../register");
|
23 | unloadModule("./cli/cli");
|
24 | unloadModule("./lib/hardhat-lib");
|
25 | }
|
26 | exports.resetHardhatContext = resetHardhatContext;
|
27 | function unloadModule(path) {
|
28 | try {
|
29 | delete require.cache[require.resolve(path)];
|
30 | }
|
31 | catch {
|
32 |
|
33 | }
|
34 | }
|
35 |
|
\ | No newline at end of file |