From 94c818140ef019fdc63cd53c6a9aa237abf4351f Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Wed, 21 Feb 2024 18:44:49 +0100 Subject: [PATCH] fix(watcher): watch `.config` and all supported extensions --- src/watch.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/watch.ts b/src/watch.ts index d4ca696..c34316a 100644 --- a/src/watch.ts +++ b/src/watch.ts @@ -8,7 +8,7 @@ import type { ResolvedConfig, LoadConfigOptions, } from "./types"; -import { loadConfig } from "./loader"; +import { SUPPORTED_EXTENSIONS, loadConfig } from "./loader"; export type ConfigWatcher< T extends UserInputConfig = UserInputConfig, @@ -64,9 +64,15 @@ export async function watchConfig< (config.layers || []) .filter((l) => l.cwd) .flatMap((l) => [ - ...["ts", "js", "mjs", "cjs", "cts", "mts", "json"].map((ext) => - resolve(l.cwd!, configFileName + "." + ext), - ), + ...SUPPORTED_EXTENSIONS.flatMap((ext) => [ + resolve(l.cwd!, configFileName + ext), + resolve(l.cwd!, ".config", configFileName + ext), + resolve( + l.cwd!, + ".config", + configFileName.replace(/\.config$/, "") + ext, + ), + ]), l.source && resolve(l.cwd!, l.source), // TODO: Support watching rc from home and workspace options.rcFile &&