@@ -5,9 +5,10 @@ import { deserialize, serialize } from 'node:v8';
55import { version } from '../version.ts' ;
66import { debugLog } from './debug.ts' ;
77import { isDirectory , isFile } from './fs.ts' ;
8+ import type { Gitignores } from './glob-core.ts' ;
89import { dirname } from './path.ts' ;
910
10- interface PerDirIgnores {
11+ interface SerializedGitignores {
1112 ignores : string [ ] ;
1213 unignores : string [ ] ;
1314}
@@ -20,7 +21,7 @@ interface GitignoreCacheEntry {
2021 ignores : string [ ] ;
2122 unignores : string [ ] ;
2223 /** Absolute dir path → cached ignores/unignores for that dir */
23- perDirIgnores : Record < string , PerDirIgnores > ;
24+ perDirIgnores : Record < string , SerializedGitignores > ;
2425 /** Sorted workspace dirs, joined with \0 — invalidates when workspace set changes */
2526 workspaceDirsKey : string ;
2627}
@@ -29,7 +30,7 @@ export interface CachedGitignoreResult {
2930 ignores : Set < string > ;
3031 unignores : Set < string > ;
3132 gitignoreFiles : string [ ] ;
32- perDirIgnores : Map < string , { ignores : Set < string > ; unignores : Set < string > } > ;
33+ perDirIgnores : Map < string , Gitignores > ;
3334}
3435
3536const CACHE_FILENAME = `gitignore-${ version } .cache` ;
@@ -84,7 +85,7 @@ export const getCachedGitignore = (cwd: string, workspaceDirs?: Set<string>): Ca
8485 isDirty = true ;
8586 return undefined ;
8687 }
87- const perDirIgnores = new Map < string , { ignores : Set < string > ; unignores : Set < string > } > ( ) ;
88+ const perDirIgnores = new Map < string , Gitignores > ( ) ;
8889 for ( const dir in entry . perDirIgnores ) {
8990 const data = entry . perDirIgnores [ dir ] ;
9091 perDirIgnores . set ( dir , { ignores : new Set ( data . ignores ) , unignores : new Set ( data . unignores ) } ) ;
@@ -103,7 +104,7 @@ export const setCachedGitignore = (
103104 gitignoreFiles : string [ ] ,
104105 ignores : Set < string > ,
105106 unignores : Set < string > ,
106- perDirIgnores : Map < string , { ignores : Set < string > ; unignores : Set < string > } >
107+ perDirIgnores : Map < string , Gitignores >
107108) : void => {
108109 if ( ! cache ) return ;
109110 const mtimes : number [ ] = [ ] ;
@@ -117,7 +118,7 @@ export const setCachedGitignore = (
117118 // File was removed between read and stat; skip rather than poison cache
118119 }
119120 }
120- const perDir : Record < string , PerDirIgnores > = { } ;
121+ const perDir : Record < string , SerializedGitignores > = { } ;
121122 for ( const [ dir , data ] of perDirIgnores ) {
122123 perDir [ dir ] = { ignores : [ ...data . ignores ] , unignores : [ ...data . unignores ] } ;
123124 }
0 commit comments