diff --git a/README.md b/README.md index 25db1e22..4a8b3e78 100644 --- a/README.md +++ b/README.md @@ -234,6 +234,27 @@ Any correct pattern(s). See [Options](#options-1) section. +#### `isDynamicPattern(pattern, [options])` + +```js +fg.isDynamicPattern('*'); // true +fg.isDynamicPattern('abc'); // false +``` + +#### pattern + +* Required: `true` +* Type: `string` + +Any correct pattern. + +#### [options] + +* Required: `false` +* Type: [`Options`](#options-1) + +See [Options](#options-1) section. + ## Options ### Common options diff --git a/src/index.spec.ts b/src/index.spec.ts index cc9c654c..46357745 100644 --- a/src/index.spec.ts +++ b/src/index.spec.ts @@ -174,4 +174,14 @@ describe('Package', () => { assert.deepStrictEqual(actual, expected); }); }); + + describe('.isDynamicPattern', () => { + it('should return true for dynamic pattern', () => { + assert.ok(pkg.isDynamicPattern('*')); + }); + + it('should return false for static pattern', () => { + assert.ok(!pkg.isDynamicPattern('abc')); + }); + }); }); diff --git a/src/index.ts b/src/index.ts index b0bc33b0..36bfedee 100644 --- a/src/index.ts +++ b/src/index.ts @@ -63,6 +63,14 @@ namespace FastGlob { return taskManager.generate(patterns, settings); } + + export function isDynamicPattern(source: PatternInternal, options?: OptionsInternal): boolean { + assertPatternsInput(source); + + const settings = new Settings(options); + + return utils.pattern.isDynamicPattern(source, settings); + } } function getWorks(source: PatternInternal | PatternInternal[], _Provider: new (settings: Settings) => Provider, options?: OptionsInternal): T[] {