antfu-collective / unconfig

A universal solution for loading configurations.
MIT License
595 stars 19 forks source link

Allow glob pattern in sources #16

Open ecstrema opened 2 years ago

ecstrema commented 2 years ago

Suppose I want to find all config files below the current directory, I'd like to be able to do something like:

const { config, sources } = await unconfigLoad<MyConfig>({
    cwd: directory,
    sources: [
        {
            files: "**/my.config",
            extensions: ["js", "ts"]
        }
    ]
});

Does that introduce any weird complexity?

Great package btw. Super useful.

antfu commented 2 years ago

Sounds reasonable, PR welome

azaleta commented 2 years ago

according to the current source (method [findUp] in fs.ts)

when we passing FindUpOptions = {multiple: true} then we will check all files in the [parent] path only like: /project/myprj -> /project -> /

should we browse the both sides as default? (parent and child) or add a new option for choosing which direction (parent or child) to check?

ecstrema commented 2 years ago

Sorry, I should have gotten back to this sooner. I ended up realizing that what I was about to implement was probably not be super useful for users, and might even complicate some things.

I do not need this anymore, feel free to close this issue.