@@ -176,9 +176,9 @@ export async function updateProject(dir: string) {
176176 // Update routes folder
177177 const project = new tsmorph . Project ( ) ;
178178
179- // First pass: count files (without storing them) so we can size the progress
180- // bar while still skipping heavy dirs early .
181- let totalFiles = 0 ;
179+ // First pass: collect file paths so we can size the progress bar and avoid
180+ // walking the tree twice .
181+ const filesToProcess : string [ ] = [ ] ;
182182 let userFileCount = 0 ;
183183 for await (
184184 const entry of walk ( dir , {
@@ -188,9 +188,10 @@ export async function updateProject(dir: string) {
188188 skip : [ SKIP_DIRS ] ,
189189 } )
190190 ) {
191- totalFiles ++ ;
191+ filesToProcess . push ( entry . path ) ;
192192 if ( ! HIDE_FILES . test ( entry . path ) ) userFileCount ++ ;
193193 }
194+ const totalFiles = filesToProcess . length ;
194195
195196 // deno-lint-ignore no-console
196197 console . log ( colors . cyan ( `📁 Found ${ userFileCount } files to process` ) ) ;
@@ -219,15 +220,8 @@ export async function updateProject(dir: string) {
219220 // Second pass: process each file one-by-one to keep memory flat. We add a
220221 // SourceFile, transform it, then immediately forget it so ts-morph releases
221222 // the AST from memory.
222- for await (
223- const entry of walk ( dir , {
224- includeDirs : false ,
225- includeFiles : true ,
226- exts : [ "js" , "jsx" , "ts" , "tsx" ] ,
227- skip : [ SKIP_DIRS ] ,
228- } )
229- ) {
230- const sourceFile = project . addSourceFileAtPath ( entry . path ) ;
223+ for ( const filePath of filesToProcess ) {
224+ const sourceFile = project . addSourceFileAtPath ( filePath ) ;
231225 try {
232226 const wasModified = await updateFile ( sourceFile ) ;
233227 if ( wasModified ) {
0 commit comments