@@ -54,13 +54,24 @@ function getChangedMdxFiles(srcPagesPath: string): string[] {
5454 return findMdxFiles ( srcPagesPath ) ;
5555 }
5656
57+ const outputDir = path . join ( process . cwd ( ) , '..' , 'public' , 'llms' ) ;
58+ const hasExistingOutput = fs . existsSync ( outputDir ) &&
59+ fs . readdirSync ( outputDir ) . length > 0 ;
60+
61+ if ( ! hasExistingOutput ) {
62+ console . log ( 'No existing output detected, processing all files (fresh build)' ) ;
63+ return findMdxFiles ( srcPagesPath ) ;
64+ }
65+
66+ console . log ( 'Existing output detected, attempting git change detection' ) ;
67+
5768 let gitCommand = 'git diff --name-only HEAD~1' ;
5869
5970 try {
6071 execSync ( 'git rev-parse HEAD~1' , { stdio : 'ignore' } ) ;
6172 } catch {
62- console . log ( 'No previous commit found, getting all tracked files' ) ;
63- gitCommand = 'git ls-files' ;
73+ console . log ( 'No previous commit found, processing all files' ) ;
74+ return findMdxFiles ( srcPagesPath ) ;
6475 }
6576
6677 const changedFiles = execSync ( gitCommand , { encoding : 'utf-8' } )
@@ -72,11 +83,8 @@ function getChangedMdxFiles(srcPagesPath: string): string[] {
7283 console . log ( `Git detected ${ changedFiles . length } changed MDX files` ) ;
7384
7485 if ( changedFiles . length === 0 ) {
75- const allFiles = findMdxFiles ( srcPagesPath ) ;
76- if ( allFiles . length > 0 ) {
77- console . log ( 'No changed files detected but MDX files exist, processing all files as fallback' ) ;
78- return allFiles ;
79- }
86+ console . log ( 'No changed files detected, skipping processing' ) ;
87+ return [ ] ;
8088 }
8189
8290 return changedFiles ;
0 commit comments