Files
smartwatch/readme.hints.md

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: chokidar 5.x and picomatch
  • Historical: Was previously using @tempfix/watcher before 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

  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 5.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.

Dev Dependencies (2024)

  • Using @git.zone/tstest v3.x with tapbundle (import { tap, expect } from '@git.zone/tstest/tapbundle')
  • Removed deprecated @push.rocks/tapbundle