Skip to content

Commit

Permalink
Update resetBuidlerContext
Browse files Browse the repository at this point in the history
  • Loading branch information
alcuadrado committed Sep 11, 2019
1 parent 464d55b commit d6242c3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/buidler-core/src/internal/reset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* manually with `unloadModule`.
*/
import { BuidlerContext } from "./context";
import { getUserConfigPath } from "./core/project-structure";
import { globSync } from "./util/glob";

export function resetBuidlerContext() {
Expand All @@ -17,6 +18,19 @@ export function resetBuidlerContext() {
}
// unload config file too.
unloadModule(ctx.environment.config.paths.configFile);
} else {
// We may get here if loading the config has thrown, so be unload it
let configPath: string | undefined;

try {
configPath = getUserConfigPath();
} catch (error) {
// We weren't in a buidler project
}

if (configPath !== undefined) {
unloadModule(configPath);
}
}
BuidlerContext.deleteBuidlerContext();
}
Expand Down

0 comments on commit d6242c3

Please sign in to comment.