feat(Smartchok): Migrate to chokidar 4.x with picomatch glob support, update documentation and tests

This commit is contained in:
Juergen Kunz
2025-06-26 23:15:42 +00:00
parent 3444b7c74d
commit d7a05abfa2
9 changed files with 8633 additions and 4030 deletions

View File

@ -1 +1,29 @@
# 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 and `picomatch`
### 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
1. **Glob pattern extraction**: The `getGlobBase()` method extracts base directories from glob patterns
2. **Pattern matching**: Each glob pattern is compiled to a picomatch matcher function
3. **Event filtering**: File system events are filtered based on glob patterns before being emitted
4. **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 events
- `addDir`, `unlinkDir`: Directory events
- `error`: Error events
- `raw`: Raw events from underlying watchers
- `ready`: Emitted when initial scan is complete
### Testing
All existing tests pass without modification, confirming backward compatibility is maintained.