@@ -18,6 +18,7 @@ export class MarkdownPatternsEngine<
18
18
private _configSchema ;
19
19
private _cwd ;
20
20
private _queryEngine ;
21
+ private _glob : string = "**/*.md" ;
21
22
private _patternsPromise : Promise < Pattern < CONFIG_SCHEMA > [ ] > | null = null ;
22
23
private _patternsMapPromise : Promise <
23
24
Map < string , Pattern < CONFIG_SCHEMA > >
@@ -30,10 +31,12 @@ export class MarkdownPatternsEngine<
30
31
cwd : FsDir ,
31
32
queryEngine : QueryEngine < any , INPUT > ,
32
33
configSchema : CONFIG_SCHEMA ,
34
+ glob : string = "**/*.md" ,
33
35
) {
34
36
this . _cwd = cwd ;
35
37
this . _queryEngine = queryEngine ;
36
38
this . _configSchema = configSchema ;
39
+ this . _glob = glob ;
37
40
}
38
41
39
42
public static cwd < INPUT = unknown > ( cwd : FsDir ) {
@@ -54,7 +57,7 @@ export class MarkdownPatternsEngine<
54
57
const newSchema = this . _configSchema . omit ( { query : true } ) . extend ( {
55
58
query : queryEngine . schema ,
56
59
} ) as CONFIG_SCHEMA ;
57
- return new MarkdownPatternsEngine ( this . _cwd , queryEngine , newSchema ) ;
60
+ return new MarkdownPatternsEngine ( this . _cwd , queryEngine , newSchema , this . _glob ) ;
58
61
}
59
62
60
63
public setConfigSchema < NEW_CONFIG_SCHEMA extends z . ZodObject < any > > (
@@ -68,11 +71,16 @@ export class MarkdownPatternsEngine<
68
71
} ) as NEW_CONFIG_SCHEMA extends z . ZodObject < infer T >
69
72
? z . ZodObject < T & { query : z . ZodType < unknown > } >
70
73
: never ,
74
+ this . _glob ,
71
75
) ;
72
76
}
73
77
78
+ public setGlob ( glob : string ) {
79
+ return new MarkdownPatternsEngine ( this . _cwd , this . _queryEngine , this . _configSchema , glob ) ;
80
+ }
81
+
74
82
public async refreshPatterns ( ) {
75
- this . _patternsPromise = getPatterns ( this . _cwd , this . schema ) ;
83
+ this . _patternsPromise = getPatterns ( this . _cwd , this . schema , this . _glob ) ;
76
84
this . _patternsMapPromise = this . _patternsPromise . then (
77
85
( patterns ) =>
78
86
new Map ( patterns . map ( ( pattern ) => [ pattern . $name , pattern ] ) ) ,
@@ -82,7 +90,7 @@ export class MarkdownPatternsEngine<
82
90
83
91
public async getPatterns ( ) {
84
92
if ( ! this . _patternsPromise ) {
85
- this . _patternsPromise = getPatterns ( this . _cwd , this . schema ) ;
93
+ this . _patternsPromise = getPatterns ( this . _cwd , this . schema , this . _glob ) ;
86
94
}
87
95
return this . _patternsPromise ;
88
96
}
0 commit comments