1.2 KiB
1.2 KiB
smartchok - Technical Hints
Chokidar 4.x Migration (2024)
The module has been migrated from @tempfix/watcher
to chokidar
4.x. Key changes:
Dependencies
- Removed:
@tempfix/watcher
(a fork of fabiospampinato/watcher) - Added:
chokidar
4.x andpicomatch
Why picomatch?
Chokidar 4.x removed built-in glob pattern support. We use picomatch
to maintain backward compatibility and provide glob pattern matching functionality.
Implementation Details
- Glob pattern extraction: The
getGlobBase()
method extracts base directories from glob patterns - Pattern matching: Each glob pattern is compiled to a picomatch matcher function
- Event filtering: File system events are filtered based on glob patterns before being emitted
- Path normalization: Paths are normalized to handle different formats (with/without leading ./)
Event Handling
Chokidar 4.x events are mapped 1:1 with smartchok events:
add
,change
,unlink
: File eventsaddDir
,unlinkDir
: Directory eventserror
: Error eventsraw
: Raw events from underlying watchersready
: Emitted when initial scan is complete
Testing
All existing tests pass without modification, confirming backward compatibility is maintained.