From d6242c37c23f83b95ecb81c451e120bd345cd221 Mon Sep 17 00:00:00 2001 From: Patricio Palladino Date: Wed, 11 Sep 2019 17:53:40 -0300 Subject: [PATCH] Update resetBuidlerContext --- packages/buidler-core/src/internal/reset.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/buidler-core/src/internal/reset.ts b/packages/buidler-core/src/internal/reset.ts index 5fbc7140c3..94662811dc 100644 --- a/packages/buidler-core/src/internal/reset.ts +++ b/packages/buidler-core/src/internal/reset.ts @@ -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() { @@ -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(); }