Function: Glob()
Glob(
pattern,options?):Promise<string[]>
Find the files and directories matching glob patterns. A pattern is made of segments separated by / on every platform (\ is not a separator, it escapes the next character), with: * (any characters in a name), ** alone in a segment (zero or more directories), ? (one character), [...] (one of the characters, [!...] one not listed), {a,b} (alternatives) and {1..3} (ranges). A pattern ending with / matches the directories only; a pattern without wildcard gives its path when it exists. The names starting with a dot are only matched as options.dot says.
The unreadable directories and the broken links are skipped silently: a pattern matching nothing gives [], it never rejects for a path missing.
Parameters
pattern
string | string[]
A pattern or several (their results are merged), relative to options.cwd or absolute; an empty array gives [].
options?
How the paths are matched and given, see GlobOptions.
Returns
Promise<string[]>
A promise of the matching paths, sorted, without duplicates, normalized with the separators of the platform (./src/*.ts gives src/a.ts); ** alone includes ., the base directory itself.
Example
import {Glob} from 'lakutata/utils'
//The TypeScript sources, without the tests
const sources: string[] = await Glob('src/**/*.ts', {ignore: 'src/tests/**'})
console.log(sources)
//['src/index.ts', 'src/lib/a.ts']