1.4 KiB
1.4 KiB
smartchok - Technical Hints
Chokidar 5.x Migration (2024)
The module has been migrated to chokidar 5.x (from 4.x). Key changes:
Dependencies
- Current:
chokidar5.x andpicomatch - Historical: Was previously using
@tempfix/watcherbefore chokidar 4.x
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 5.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.
Dev Dependencies (2024)
- Using
@git.zone/tstestv3.x with tapbundle (import { tap, expect } from '@git.zone/tstest/tapbundle') - Removed deprecated
@push.rocks/tapbundle