unconfig icon indicating copy to clipboard operation
unconfig copied to clipboard

Allow glob pattern in sources

Open ecstrema opened this issue 3 years ago • 3 comments

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.

ecstrema avatar Feb 24 '22 16:02 ecstrema

Sounds reasonable, PR welome

antfu avatar Feb 24 '22 17:02 antfu

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?

azaleta avatar Mar 22 '22 03:03 azaleta

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.

ecstrema avatar Mar 22 '22 19:03 ecstrema