@@ -8,7 +8,7 @@ import { debugLogObject } from './debug.ts';
88import { isDirectory , isFile } from './fs.ts' ;
99import { timerify } from './Performance.ts' ;
1010import { expandIgnorePatterns , parseAndConvertGitignorePatterns } from './parse-and-convert-gitignores.ts' ;
11- import { basename , dirname , join , relative , toPosix } from './path.ts' ;
11+ import { dirname , join , relative , toPosix } from './path.ts' ;
1212
1313type Options = { gitignore : boolean ; cwd : string } ;
1414
@@ -167,15 +167,16 @@ export const findAndParseGitignores = async (cwd: string, workspaceDirs?: Set<st
167167 }
168168 }
169169
170+ const cwdPrefixLen = cwd . length + 1 ;
170171 const walkGitignores = async ( ) => {
171172 await new fdir ( )
172173 . withFullPaths ( )
173174 . exclude ( ( _dirName : string , dirPath : string ) => {
174- const absPath = toPosix ( dirPath . endsWith ( '/' ) ? dirPath . slice ( 0 , - 1 ) : dirPath ) ;
175- return ( isRelevantDir && ! isRelevantDir ( absPath ) ) || getMatcher ( ) ( relative ( cwd , absPath ) ) ;
175+ const absPath = toPosix ( dirPath . slice ( 0 , - 1 ) ) ;
176+ return ( isRelevantDir && ! isRelevantDir ( absPath ) ) || getMatcher ( ) ( absPath . slice ( cwdPrefixLen ) ) ;
176177 } )
177178 . filter ( ( filePath : string , isDir : boolean ) => {
178- if ( isDir || basename ( filePath ) !== ' .gitignore') return false ;
179+ if ( isDir || ! filePath . endsWith ( '/ .gitignore') ) return false ;
179180 addFile ( filePath ) ;
180181 return true ;
181182 } )
0 commit comments