Skip to content
This repository has been archived by the owner on Jan 14, 2021. It is now read-only.

File system watcher based on chokidar that emits add/change/rename/unlink events.

License

Notifications You must be signed in to change notification settings

fabiospampinato/chokidar-watcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chokidar Watcher

File system watcher based on chokidar that emits add/change/rename/unlink events.

The main reason this library exists is to provide a "rename" event too, if you don't need that you might just want to use chokidar directly.

Install

npm install --save chokidar-watcher

API

This library provides the following interface:

type Handler = ( filePath: string, nextFilePathOrStats?: import ( 'fs' ).Stats | string ) => void;

type Handlers = {
  add?: ( filePath: string, stats: fs.Stats ) => void,
  change?: ( filePath: string, stats: fs.Stats ) => void,
  rename?: ( prevFilePath: string, nextFilePath: string ) => void,
  unlink?: ( filePath: string ) => void
};

function watcher ( paths: ChokidarPaths, options: ChokidarOptions, handler: Handler ): ChokidarWatcher // Basically the same API as chokidar, plus the "handler" function which will handle all events
function watcher ( paths: ChokidarPaths, options: ChokidarOptions, handlers: Handlers ): ChokidarWatcher // Basically the same API as chokidar, plus the "handlers" object

Usage

import watcher from 'chokidar-watcher';

const options = {
  usePolling: true,
  interval: 100
};

const handlers = {
  add ( filePath, stats ) { /* ... */ },
  change ( filePath, stats ) { /* ... */ },
  rename ( prevFilePath, nextFilePath ) { /* ... */ },
  unlink ( filePath ) { /* ... */ }
};

watcher ( '/Users/fabio/Desktop', options, handlers );

License

MIT © Fabio Spampinato

About

File system watcher based on chokidar that emits add/change/rename/unlink events.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published