1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | const context_1 = require("./context");
|
10 | const project_structure_1 = require("./core/project-structure");
|
11 | function resetBuidlerContext() {
|
12 | if (context_1.BuidlerContext.isCreated()) {
|
13 | const ctx = context_1.BuidlerContext.getBuidlerContext();
|
14 | const globalAsAny = global;
|
15 | if (ctx.environment !== undefined) {
|
16 | for (const key of Object.keys(ctx.environment)) {
|
17 | globalAsAny[key] = undefined;
|
18 | }
|
19 |
|
20 | unloadModule(ctx.environment.config.paths.configFile);
|
21 | }
|
22 | else {
|
23 |
|
24 | let configPath;
|
25 | try {
|
26 | configPath = project_structure_1.getUserConfigPath();
|
27 | }
|
28 | catch (error) {
|
29 |
|
30 | }
|
31 | if (configPath !== undefined) {
|
32 | unloadModule(configPath);
|
33 | }
|
34 | }
|
35 | context_1.BuidlerContext.deleteBuidlerContext();
|
36 | }
|
37 |
|
38 | unloadModule("../register");
|
39 | unloadModule("./cli/cli");
|
40 | unloadModule("./lib/buidler-lib");
|
41 | }
|
42 | exports.resetBuidlerContext = resetBuidlerContext;
|
43 | function unloadModule(path) {
|
44 | try {
|
45 | delete require.cache[require.resolve(path)];
|
46 | }
|
47 | catch (err) {
|
48 |
|
49 | }
|
50 | }
|
51 |
|
\ | No newline at end of file |