fast-glob icon indicating copy to clipboard operation
fast-glob copied to clipboard

[Feature Request] provide a test function to see if a path is matched by target pattern(s)

Open e-cloud opened this issue 5 years ago • 3 comments

Assume the future method is called isMatch(filePath, patterns, options)

then I want to achieve the follow:

fastGlob.isMatch('./package.json', ['src/*.json'])
// return false

Note: A hidden requirement is I want to keep the ability to constraint the patterns under specify scope (aka cwd). Otherwise i could use micromatch directly.

guided from https://github.com/sindresorhus/globby/issues/93

e-cloud avatar Nov 04 '18 02:11 e-cloud

I correctly understand that under the options argument you understand options for FastGlob?

mrmlnc avatar Nov 05 '18 13:11 mrmlnc

@mrmlnc sorry, I don't understand your words. In the provided example I just use the default options.

e-cloud avatar Nov 05 '18 13:11 e-cloud

I'll mark this question as an improvement. But I'm not sure that this method is needed within this package.

mrmlnc avatar Nov 10 '18 10:11 mrmlnc

It is not planned to implement, as this functionality is outside the scope of this package. This package provides functionality for searching entries by glob patterns and utilities for preparing these glob patterns.

The requested functionality directly relates to matching a mask to a path. You can use micromatch or any other analog for this purpose.

mrmlnc avatar Apr 29 '23 16:04 mrmlnc