@@ -5,7 +5,7 @@ import { type CommandOptions } from "./commandutil";
55import { headerComment } from "./genutil" ;
66import type { Target } from "./genutil" ;
77
8- const { walk , readFileUtf8 } = systemUtils ;
8+ const { readFileUtf8 } = systemUtils ;
99
1010// generate per-file queries
1111// generate queries in a single file
@@ -42,7 +42,6 @@ currently supported.`);
4242 console . log ( `Detected schema directory: ${ params . schemaDir } ` ) ;
4343 const matches = await getMatches (
4444 root ,
45- params . schemaDir ,
4645 params . options . patterns ,
4746 ) ;
4847 if ( matches . length === 0 ) {
@@ -97,8 +96,7 @@ currently supported.`);
9796 ) ;
9897 if ( ! wasError ) {
9998 console . log (
100- `Generating query file${
101- Object . keys ( filesByExtension ) . length > 1 ? "s" : ""
99+ `Generating query file${ Object . keys ( filesByExtension ) . length > 1 ? "s" : ""
102100 } ...`,
103101 ) ;
104102 for ( const [ extension , file ] of Object . entries ( filesByExtension ) ) {
@@ -113,7 +111,7 @@ currently supported.`);
113111 await fs . writeFile (
114112 filePath ,
115113 headerComment +
116- `${ stringifyImports ( file . imports ) } \n\n${ file . contents } ` ,
114+ `${ stringifyImports ( file . imports ) } \n\n${ file . contents } ` ,
117115 ) ;
118116 }
119117 }
@@ -167,39 +165,28 @@ export function stringifyImports(imports: ImportMap) {
167165
168166async function getMatches (
169167 root : string ,
170- schemaDir : string ,
171168 patterns ?: string [ ] ,
172169) {
173- if ( patterns && patterns . length > 0 ) {
174- // Use globby to match files with the provided patterns
175- const { globby } = await import ( "globby" ) ;
176-
177- const allFiles = await globby ( patterns , {
178- cwd : process . cwd ( ) ,
179- absolute : true ,
180- onlyFiles : true ,
181- expandDirectories : {
182- extensions : [ "edgeql" ] ,
183- } ,
184- ignore : [
185- "node_modules/**" ,
186- `${ schemaDir } /migrations/**` ,
187- `${ schemaDir } /fixups/**` ,
188- ] ,
189- } ) ;
190-
191- return allFiles ;
192- }
193-
194- // Default behavior - walk all files
195- return walk ( root , {
196- match : [ / [ ^ / ] \. e d g e q l $ / ] ,
197- skip : [
198- / n o d e _ m o d u l e s / ,
199- RegExp ( `${ schemaDir } \\${ path . sep } migrations` ) ,
200- RegExp ( `${ schemaDir } \\${ path . sep } fixups` ) ,
170+ // Single code path using globby for both cases
171+ const { globby } = await import ( "globby" ) ;
172+
173+ const searchPatterns = patterns && patterns . length > 0 ? patterns : [ "." ] ;
174+
175+ const allFiles = await globby ( searchPatterns , {
176+ cwd : root ,
177+ absolute : true ,
178+ onlyFiles : true ,
179+ expandDirectories : {
180+ extensions : [ "edgeql" ] ,
181+ } ,
182+ ignore : [
183+ "node_modules/**" ,
184+ `**/migrations/**` ,
185+ `**/fixups/**` ,
201186 ] ,
202187 } ) ;
188+
189+ return allFiles ;
203190}
204191
205192// const targetToExtension: {[k in Target]: string} = {
0 commit comments