BREAKING CHANGE(smartwatch): Introduce Smartwatch: cross-runtime native file watching for Node.js, Deno and Bun; rename smartchok to smartwatch and bump major version to 2.0.0
This commit is contained in:
26
readme.md
26
readme.md
@@ -1,4 +1,4 @@
|
||||
# @push.rocks/smartchok
|
||||
# @push.rocks/smartwatch
|
||||
|
||||
A smart wrapper for chokidar 5.x with glob pattern support, RxJS observable integration, and enhanced file watching features.
|
||||
|
||||
@@ -9,9 +9,9 @@ For reporting bugs, issues, or security vulnerabilities, please visit [community
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install @push.rocks/smartchok
|
||||
npm install @push.rocks/smartwatch
|
||||
# or
|
||||
pnpm add @push.rocks/smartchok
|
||||
pnpm add @push.rocks/smartwatch
|
||||
```
|
||||
|
||||
## Features
|
||||
@@ -27,10 +27,10 @@ pnpm add @push.rocks/smartchok
|
||||
### Basic Setup
|
||||
|
||||
```typescript
|
||||
import { Smartchok } from '@push.rocks/smartchok';
|
||||
import { Smartwatch } from '@push.rocks/smartwatch';
|
||||
|
||||
// Create a watcher with glob patterns
|
||||
const watcher = new Smartchok([
|
||||
const watcher = new Smartwatch([
|
||||
'./src/**/*.ts', // Watch all TypeScript files in src
|
||||
'./public/assets/**/*' // Watch all files in public/assets
|
||||
]);
|
||||
@@ -87,7 +87,7 @@ unlinkObservable.subscribe(([path]) => {
|
||||
Add or remove patterns while the watcher is running:
|
||||
|
||||
```typescript
|
||||
const watcher = new Smartchok(['./src/**/*.ts']);
|
||||
const watcher = new Smartwatch(['./src/**/*.ts']);
|
||||
await watcher.start();
|
||||
|
||||
// Add more patterns to watch
|
||||
@@ -107,11 +107,11 @@ await watcher.stop();
|
||||
### Complete Example
|
||||
|
||||
```typescript
|
||||
import { Smartchok } from '@push.rocks/smartchok';
|
||||
import { Smartwatch } from '@push.rocks/smartwatch';
|
||||
|
||||
async function watchProject() {
|
||||
// Initialize with patterns
|
||||
const watcher = new Smartchok([
|
||||
const watcher = new Smartwatch([
|
||||
'./src/**/*.ts',
|
||||
'./package.json'
|
||||
]);
|
||||
@@ -152,24 +152,24 @@ watchProject();
|
||||
|
||||
## How It Works
|
||||
|
||||
Since chokidar 4.x+ no longer supports glob patterns natively, smartchok handles glob pattern matching internally using [picomatch](https://github.com/micromatch/picomatch). This means you get the familiar glob syntax while benefiting from chokidar's efficient file watching capabilities.
|
||||
Since chokidar 4.x+ no longer supports glob patterns natively, smartwatch handles glob pattern matching internally using [picomatch](https://github.com/micromatch/picomatch). This means you get the familiar glob syntax while benefiting from chokidar's efficient file watching capabilities.
|
||||
|
||||
When you provide glob patterns:
|
||||
1. **Base path extraction** - smartchok extracts the static base path from each pattern
|
||||
1. **Base path extraction** - smartwatch extracts the static base path from each pattern
|
||||
2. **Efficient watching** - chokidar watches the base directories
|
||||
3. **Pattern filtering** - Events are filtered through picomatch matchers before being emitted
|
||||
|
||||
## API Reference
|
||||
|
||||
### `Smartchok`
|
||||
### `Smartwatch`
|
||||
|
||||
#### Constructor
|
||||
|
||||
```typescript
|
||||
new Smartchok(patterns: string[])
|
||||
new Smartwatch(patterns: string[])
|
||||
```
|
||||
|
||||
Creates a new Smartchok instance with the given glob patterns.
|
||||
Creates a new Smartwatch instance with the given glob patterns.
|
||||
|
||||
#### Methods
|
||||
|
||||
|
||||
Reference in New Issue
Block a user