Skip to content

Commit

Permalink
fix(watcher): watch .config and all supported extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Feb 21, 2024
1 parent a8b3a1d commit 94c8181
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/watch.ts
Expand Up @@ -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,
Expand Down Expand Up @@ -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 &&
Expand Down

0 comments on commit 94c8181

Please sign in to comment.