2025-06-26 23:15:42 +00:00
# smartchok - Technical Hints
2025-11-29 21:05:51 +00:00
## Chokidar 5.x Migration (2024)
2025-06-26 23:15:42 +00:00
2025-11-29 21:05:51 +00:00
The module has been migrated to `chokidar` 5.x (from 4.x). Key changes:
2025-06-26 23:15:42 +00:00
### Dependencies
2025-11-29 21:05:51 +00:00
- **Current**: `chokidar` 5.x and `picomatch`
- **Historical**: Was previously using `@tempfix/watcher` before chokidar 4.x
2025-06-26 23:15:42 +00:00
### Why picomatch?
2025-11-29 21:05:51 +00:00
Chokidar 4.x+ removed built-in glob pattern support. We use `picomatch` to maintain backward compatibility and provide glob pattern matching functionality.
2025-06-26 23:15:42 +00:00
### 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
2025-11-29 21:05:51 +00:00
Chokidar 5.x events are mapped 1:1 with smartchok events:
2025-06-26 23:15:42 +00:00
- `add` , `change` , `unlink` : File events
2025-11-29 21:05:51 +00:00
- `addDir` , `unlinkDir` : Directory events
2025-06-26 23:15:42 +00:00
- `error` : Error events
- `raw` : Raw events from underlying watchers
- `ready` : Emitted when initial scan is complete
### Testing
2025-11-29 21:05:51 +00:00
All existing tests pass without modification, confirming backward compatibility is maintained.
## Dev Dependencies (2024)
- Using `@git.zone/tstest` v3.x with tapbundle (`import { tap, expect } from '@git.zone/tstest/tapbundle'` )
- Removed deprecated `@push.rocks/tapbundle`