@@ -47,6 +47,8 @@ export type FileEntryCacheOptions = {
4747export type GetFileDescriptorOptions = {
4848 /** Whether to use checksum for this specific file check instead of modified time (mtime) (overrides instance setting) */
4949 useCheckSum ?: boolean ;
50+ /** Whether to use file modified time for change detection (default: true) */
51+ useModifiedTime ?: boolean ;
5052} ;
5153
5254export type FileDescriptor = {
@@ -147,6 +149,7 @@ export class FileEntryCache {
147149 private _restrictAccessToCwd = false ;
148150 private _logger ?: ILogger ;
149151 private _useAbsolutePathAsKey = false ;
152+ private _useModifiedTime = true ;
150153
151154 /**
152155 * Create a new FileEntryCache instance
@@ -169,6 +172,10 @@ export class FileEntryCache {
169172 this . _cwd = options . cwd ;
170173 }
171174
175+ if ( options ?. useModifiedTime !== undefined ) {
176+ this . _useModifiedTime = options . useModifiedTime ;
177+ }
178+
172179 if ( options ?. restrictAccessToCwd !== undefined ) {
173180 this . _restrictAccessToCwd = options . restrictAccessToCwd ;
174181 }
@@ -262,6 +269,22 @@ export class FileEntryCache {
262269 this . _cwd = value ;
263270 }
264271
272+ /**
273+ * Get whether to use modified time for change detection
274+ * @returns {boolean } Whether modified time (mtime) is used for change detection (default: true)
275+ */
276+ public get useModifiedTime ( ) : boolean {
277+ return this . _useModifiedTime ;
278+ }
279+
280+ /**
281+ * Set whether to use modified time for change detection
282+ * @param {boolean } value - The value to set
283+ */
284+ public set useModifiedTime ( value : boolean ) {
285+ this . _useModifiedTime = value ;
286+ }
287+
265288 /**
266289 * Get whether to restrict paths to cwd boundaries
267290 * @returns {boolean } Whether strict path checking is enabled (default: true)
@@ -435,6 +458,13 @@ export class FileEntryCache {
435458 "Using checksum setting" ,
436459 ) ;
437460
461+ const useModifiedTimeValue =
462+ options ?. useModifiedTime ?? this . useModifiedTime ;
463+ this . _logger ?. debug (
464+ { useModifiedTime : useModifiedTimeValue } ,
465+ "Using modified time (mtime) setting" ,
466+ ) ;
467+
438468 try {
439469 fstat = fs . statSync ( absolutePath ) ;
440470 // Update the file stats while preserving existing meta properties
@@ -478,7 +508,7 @@ export class FileEntryCache {
478508 }
479509
480510 // If the file is in the cache, check if the file has changed
481- if ( useCheckSumValue === false && metaCache ?. mtime !== result . meta ?. mtime ) {
511+ if ( useModifiedTimeValue && metaCache ?. mtime !== result . meta ?. mtime ) {
482512 result . changed = true ;
483513 this . _logger ?. debug (
484514 { filePath, oldMtime : metaCache . mtime , newMtime : result . meta . mtime } ,
0 commit comments