From 3bd7d9db179ca9d9891d73ec97108b336056a8e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20V=C3=A1zquez=20P=C3=BAa?= Date: Fri, 7 Mar 2025 14:56:35 +0100 Subject: [PATCH] Ensure loadConfig returns the configuration if it is a new configuration Fixes #390 --- lib/util/customConfig.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/util/customConfig.js b/lib/util/customConfig.js index 1ab15994..54864527 100644 --- a/lib/util/customConfig.js +++ b/lib/util/customConfig.js @@ -38,7 +38,7 @@ function requireUncached(module) { * @param {string|Object} config * @returns `null` when unchanged, `{}` when not found */ -function loadConfig(config) { +function loadConfig(config, newConfig) { let loadedConfig = null; if (typeof config === 'string') { const resolvedPath = path.isAbsolute(config) ? config : path.join(path.resolve(), config); @@ -48,7 +48,7 @@ function loadConfig(config) { if (stats === null) { // Default to no config loadedConfig = {}; - } else if (lastModifiedDate !== mtime) { + } else if (lastModifiedDate !== mtime || newConfig) { // Load the config based on path lastModifiedDate = mtime; loadedConfig = requireUncached(resolvedPath); @@ -66,6 +66,7 @@ function loadConfig(config) { if (typeof config === 'object' && config !== null) { return config; } + lastModifiedDate = null; return {}; } } @@ -88,7 +89,7 @@ function resolve(twConfig) { if (newConfig || expired) { previousConfig = twConfig; lastCheck = now; - const userConfig = loadConfig(twConfig); + const userConfig = loadConfig(twConfig, newConfig); // userConfig is null when config file was not modified if (userConfig !== null) { mergedConfig = resolveConfig(userConfig);