Fast-Glob Pattern Syntax
fast-glob
is a powerful and efficient library for matching file paths against specified patterns, integrated within ToolX for file manipulation and searching. It uses a specific pattern syntax to define the criteria for matching file paths.
TIP
The fast-glob
library is used in ToolX to provide flexible and efficient file matching capabilities. It's crucial for operations that require pattern matching against file paths, such as filtering or searching files.
Pattern Syntax
fast-glob
uses glob pattern syntax, which allows for flexible and expressive file path matching. The syntax includes:
*
(Wildcard): Matches any number of characters (excluding directory separators).**
(Globstar): Matches any number of characters (including directory separators).?
(Single Character): Matches any single character (excluding directory separators).[seq]
(Character Set): Matches any character inseq
.!(pattern)
(Negation): Matches anything except the specifiedpattern
.@(pattern)
(Match Pattern): Matches the specifiedpattern
.+(pattern)
(One or More): Matches one or more occurrences of the specifiedpattern
.*(pattern)
(Zero or More): Matches zero or more occurrences of the specifiedpattern
.?(pattern)
(Optional): Matches zero or one occurrence of the specifiedpattern
.{a,b}
(Alternatives): Matches eithera
orb
.
Usage in ToolX
When using fast-glob
within ToolX, patterns are passed to functions that involve file searching or manipulation. Here's an example showing how fast-glob
is used in ToolX to filter files:
Example
import { Tool } from '@toolx/core';
// Example usage
const tool = new Tool(['*.js', '!test.*']);
tool.run();
In this example, uses fast-glob
patterns to include all .js
files but exclude those named test.*
.
External Library: fast-glob
fast-glob
is an external library integrated into ToolX. It provides advanced pattern matching capabilities that are essential for various file manipulation tasks. For more information on fast-glob
patterns and usage, refer to the fast-glob documentation.