Glob pattern to check if sibling folder exists

Viewed 27

Specifically, this is actually for Vite's import.meta.glob, meaning it's really for fast-glob (https://github.com/mrmlnc/fast-glob#pattern-syntax), but anyway... here's the question:

Is it possible to check if a sibling or parent folder exists to match a file using a glob pattern?

For example, let's say I have a folder structure like this

/src/lib/hi.txt

/src/foo/hi.txt
/src/foo/bar/hi.txt

/src/baz/hi.txt

/src/qux/bar/hi.txt
/src/qux/hi.txt

I want to look for any file that is sitting in a folder that has a sibling folder named bar. In this example, the glob would match with /src/foo/hi.txt and /src/qux/hi.txt

I imagined a glob like so /src/**/bar/../hi.txt would work, but the bar and .. just cancels each other out in fast-glob and I get matched with all the hi.txt files.

Is this something glob supports?

0 Answers
Related