@@ -12,21 +12,25 @@ export interface IRcappsConfig {
1212 * @param projectPath The path to the project directory
1313 * @returns The parsed configuration or null if file doesn't exist
1414 */
15- export async function readRcappsConfig ( projectPath : string ) : Promise < IRcappsConfig | null > {
15+ export async function readRcappsConfig (
16+ projectPath : string ,
17+ ) : Promise < IRcappsConfig | null > {
1618 const configPath = path . join ( projectPath , ".rcappsconfig" ) ;
17-
19+
1820 try {
1921 const configContent = await fs . promises . readFile ( configPath , "utf8" ) ;
2022 const config = JSON . parse ( configContent ) as IRcappsConfig ;
21-
23+
2224 logger . debug ( `Loaded .rcappsconfig from ${ configPath } ` ) ;
2325 return config ;
2426 } catch ( error ) {
2527 if ( ( error as NodeJS . ErrnoException ) . code === "ENOENT" ) {
26- logger . debug ( "No .rcappsconfig file found, using default configuration" ) ;
28+ logger . debug (
29+ "No .rcappsconfig file found, using default configuration" ,
30+ ) ;
2731 return null ;
2832 }
29-
33+
3034 logger . warn ( `Failed to parse .rcappsconfig file: ${ error . message } ` ) ;
3135 return null ;
3236 }
@@ -38,11 +42,14 @@ export async function readRcappsConfig(projectPath: string): Promise<IRcappsConf
3842 * @param config The .rcappsconfig configuration
3943 * @returns Combined ignore patterns
4044 */
41- export function mergeIgnorePatterns ( defaultIgnore : string [ ] , config : IRcappsConfig | null ) : string [ ] {
42- if ( ! config || ! config . ignore ) {
45+ export function mergeIgnorePatterns (
46+ defaultIgnore : string [ ] ,
47+ config : IRcappsConfig | null ,
48+ ) : string [ ] {
49+ if ( ! config ?. ignore ) {
4350 return defaultIgnore ;
4451 }
45-
52+
4653 // Combine default ignore patterns with those from .rcappsconfig
4754 // .rcappsconfig patterns take precedence (are added last)
4855 return [ ...defaultIgnore , ...config . ignore ] ;
@@ -54,16 +61,19 @@ export function mergeIgnorePatterns(defaultIgnore: string[], config: IRcappsConf
5461 * @param ignorePatterns Array of ignore patterns (glob-style)
5562 * @returns true if the file should be ignored
5663 */
57- export function shouldIgnoreFile ( filePath : string , ignorePatterns : string [ ] ) : boolean {
58- return ignorePatterns . some ( pattern => {
64+ export function shouldIgnoreFile (
65+ filePath : string ,
66+ ignorePatterns : string [ ] ,
67+ ) : boolean {
68+ return ignorePatterns . some ( ( pattern ) => {
5969 // Support both glob patterns and simple directory/file names
6070 // Check for exact matches, basename matches, and path contains matches
6171 const normalizedPath = path . normalize ( filePath ) . replace ( / \\ / g, "/" ) ;
6272 const normalizedPattern = pattern . replace ( / \\ / g, "/" ) ;
63-
73+
6474 // Simple pattern matching - check if the pattern matches the path
6575 let isMatch = false ;
66-
76+
6777 // Exact match
6878 if ( normalizedPath === normalizedPattern ) {
6979 isMatch = true ;
@@ -77,25 +87,32 @@ export function shouldIgnoreFile(filePath: string, ignorePatterns: string[]): bo
7787 isMatch = true ;
7888 }
7989 // Glob-style patterns
80- else if ( normalizedPattern . includes ( "*" ) || normalizedPattern . includes ( "?" ) ) {
90+ else if (
91+ normalizedPattern . includes ( "*" ) ||
92+ normalizedPattern . includes ( "?" )
93+ ) {
8194 // Convert simple glob pattern to regex
8295 const regexPattern = normalizedPattern
8396 . replace ( / \. / g, "\\." )
8497 . replace ( / \* / g, ".*" )
8598 . replace ( / \? / g, "." ) ;
8699 try {
87100 const regex = new RegExp ( `^${ regexPattern } $` ) ;
88- isMatch = regex . test ( normalizedPath ) || regex . test ( path . basename ( normalizedPath ) ) ;
101+ isMatch =
102+ regex . test ( normalizedPath ) ||
103+ regex . test ( path . basename ( normalizedPath ) ) ;
89104 } catch ( e ) {
90105 // If regex fails, fall back to simple contains check
91- isMatch = normalizedPath . includes ( normalizedPattern . replace ( / \* / g, "" ) ) ;
106+ isMatch = normalizedPath . includes (
107+ normalizedPattern . replace ( / \* / g, "" ) ,
108+ ) ;
92109 }
93110 }
94-
111+
95112 if ( isMatch ) {
96113 logger . debug ( `File ${ filePath } ignored by pattern: ${ pattern } ` ) ;
97114 }
98-
115+
99116 return isMatch ;
100117 } ) ;
101- }
118+ }
0 commit comments