@@ -2,6 +2,7 @@ import fs from "node:fs";
22import path from "node:path" ;
33import { describe , expect , test } from "vitest" ;
44import fileEntryCache , {
5+ type CreateOptions ,
56 FileEntryCache ,
67 type FileEntryCacheOptions ,
78} from "../src/index.js" ;
@@ -109,4 +110,33 @@ describe("eslint tests scenarios", () => {
109110 expect ( fileDescriptor2 . changed ) . toBe ( false ) ;
110111 expect ( fileDescriptor2 . meta . hash ) . toBeDefined ( ) ;
111112 } ) ;
113+
114+ test ( "create with cwd and use absolute path key" , ( ) => {
115+ const cacheDirectory = "./.cache" ;
116+ const cacheId = ".eslintcache-202121212" ;
117+ const file = "../src/index.ts" ;
118+ const useCheckSum = true ;
119+ const useAbsolutePathAsKey = true ;
120+ const cwd = cacheDirectory ;
121+
122+ const options : CreateOptions = {
123+ useCheckSum,
124+ useAbsolutePathAsKey,
125+ cwd,
126+ } ;
127+
128+ const cache = fileEntryCache . create ( cacheId , cacheDirectory , options ) ;
129+
130+ const fileDescriptor = cache . getFileDescriptor ( file ) ;
131+
132+ expect ( fileDescriptor . changed ) . toBe ( true ) ;
133+ expect ( fileDescriptor . meta . hash ) . toBeDefined ( ) ;
134+
135+ cache . reconcile ( ) ;
136+
137+ const fileDescriptor2 = cache . getFileDescriptor ( file ) ;
138+
139+ expect ( fileDescriptor2 . changed ) . toBe ( false ) ;
140+ expect ( fileDescriptor2 . meta . hash ) . toBeDefined ( ) ;
141+ } ) ;
112142} ) ;
0 commit comments