1
1
import * as path from 'path' ;
2
+ import * as fs from 'fs' ;
2
3
import * as yaml from 'js-yaml' ;
3
4
import MarkdownIt from 'markdown-it' ;
4
5
import { ContextdocsLinter } from './contextdocs_linter' ;
@@ -23,7 +24,7 @@ export class ContextLinter {
23
24
printHeader ( packageVersion , directoryPath ) ;
24
25
await this . handleContextignore ( directoryPath ) ;
25
26
await this . handleContextdocs ( directoryPath ) ;
26
- await this . handleContextFiles ( directoryPath ) ;
27
+ await this . handleContextFilesRecursively ( directoryPath ) ;
27
28
28
29
console . log ( '\nLinting completed.' ) ;
29
30
}
@@ -42,15 +43,17 @@ export class ContextLinter {
42
43
}
43
44
}
44
45
45
- private async handleContextFiles ( directoryPath : string ) : Promise < void > {
46
- const files = await getContextFiles ( directoryPath ) ;
47
- if ( files . length === 0 ) {
48
- console . log ( 'No context files found in the specified directory.' ) ;
49
- return ;
50
- }
46
+ private async handleContextFilesRecursively ( directoryPath : string ) : Promise < void > {
47
+ const entries = await fs . promises . readdir ( directoryPath , { withFileTypes : true } ) ;
51
48
52
- for ( const file of files ) {
53
- await this . lintContextFile ( path . join ( directoryPath , file ) ) ;
49
+ for ( const entry of entries ) {
50
+ const fullPath = path . join ( directoryPath , entry . name ) ;
51
+
52
+ if ( entry . isDirectory ( ) ) {
53
+ await this . handleContextFilesRecursively ( fullPath ) ;
54
+ } else if ( entry . isFile ( ) && ( entry . name . endsWith ( '.context.md' ) || entry . name . endsWith ( '.context.yaml' ) || entry . name . endsWith ( '.context.json' ) ) ) {
55
+ await this . lintContextFile ( fullPath ) ;
56
+ }
54
57
}
55
58
}
56
59
0 commit comments