Skip to content

Commit 43587f4

Browse files
committed
feat(loader): scan for config keys files
1 parent 0542960 commit 43587f4

File tree

4 files changed

+35
-8
lines changed

4 files changed

+35
-8
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
"pathe": "^1.1.2",
4848
"perfect-debounce": "^1.0.0",
4949
"pkg-types": "^1.2.1",
50-
"rc9": "^2.1.2"
50+
"rc9": "^2.1.2",
51+
"tinyglobby": "^0.2.10"
5152
},
5253
"devDependencies": {
5354
"@types/node": "^22.10.2",

pnpm-lock.yaml

+18-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/loader.ts

+14
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { homedir } from "node:os";
44
import { resolve, extname, dirname, basename, join } from "pathe";
55
import { createJiti } from "jiti";
66
import { fileURLToPath } from "mlly";
7+
import { glob } from "tinyglobby";
78
import * as rc9 from "rc9";
89
import { defu } from "defu";
910
import { hash } from "ohash";
@@ -375,6 +376,19 @@ async function resolveConfig<
375376
tryResolve(resolve(cwd, ".config", source)) ||
376377
source;
377378

379+
if (options.name) {
380+
const globExtensions = `{${SUPPORTED_EXTENSIONS.map((e) => e.slice(1)).join(",")}}`;
381+
const globPaths = await glob(
382+
[
383+
`${options.name}?(.*).config.${globExtensions}`,
384+
`.config/${options.name}?(.*)?(.config).${globExtensions}`,
385+
`.config/${options.name}/**/*?(.*)?(.config).${globExtensions}`,
386+
],
387+
{ cwd },
388+
);
389+
console.log(globPaths.map((g) => resolve(cwd, g)), res.configFile, source);
390+
}
391+
378392
if (!existsSync(res.configFile!)) {
379393
return res;
380394
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default "user_secondary";

0 commit comments

Comments
 (0)