@@ -35,7 +35,10 @@ export class GitIgnoreParser implements GitIgnoreFilter {
3535
3636 const relativeBaseDir = isExcludeFile
3737 ? '.'
38- : path . dirname ( path . relative ( this . projectRoot , patternsFilePath ) ) ;
38+ : path
39+ . dirname ( path . relative ( this . projectRoot , patternsFilePath ) )
40+ . split ( path . sep )
41+ . join ( path . posix . sep ) ;
3942
4043 return content
4144 . split ( '\n' )
@@ -68,11 +71,11 @@ export class GitIgnoreParser implements GitIgnoreFilter {
6871 if ( ! isAnchoredInFile && ! p . includes ( '/' ) ) {
6972 // If no slash and not anchored in file, it matches files in any
7073 // subdirectory.
71- newPattern = path . join ( '**' , p ) ;
74+ newPattern = path . posix . join ( '**' , p ) ;
7275 }
7376
7477 // Prepend the .gitignore file's directory.
75- newPattern = path . join ( relativeBaseDir , newPattern ) ;
78+ newPattern = path . posix . join ( relativeBaseDir , newPattern ) ;
7679
7780 // Anchor the pattern to a nested gitignore directory.
7881 if ( ! newPattern . startsWith ( '/' ) ) {
@@ -89,9 +92,6 @@ export class GitIgnoreParser implements GitIgnoreFilter {
8992 newPattern = '!' + newPattern ;
9093 }
9194
92- // Even in windows, Ignore expects forward slashes.
93- newPattern = newPattern . replace ( / \\ / g, '/' ) ;
94-
9595 return newPattern ;
9696 } )
9797 . filter ( ( p ) => p !== '' ) ;
@@ -173,6 +173,7 @@ export class GitIgnoreParser implements GitIgnoreFilter {
173173 const gitignorePath = path . join ( dir , '.gitignore' ) ;
174174 if ( fs . existsSync ( gitignorePath ) ) {
175175 const patterns = this . loadPatternsForFile ( gitignorePath ) ;
176+
176177 this . cache . set ( dir , patterns ) ;
177178 ig . add ( patterns ) ;
178179 } else {
0 commit comments