Skip to content

LeadFisherSolutions/leadwatch

Repository files navigation

File system watcher

Watch specific files, directories, deeply nested directories
Rebuild recursive when new directories found or old directories remove
Deduplicate events with debounce

Installation

npm i leadwatch --save

Usage

const DirectoryWatcher = require('leadwatch');
const watcher = new DirectoryWatcher({
  timeout: 200, // Events debouncing for queue
  ignore: [new RegExp(/[\D\d]+\.ignore\D*/)], // Ignore files and directories
  deep: false, // Include nested directories
});
watcher.watch('/home/sashapop10/Downloads');
watcher.watch('/home/sashapop10/Documents');
watcher.on('before', updates => console.log({ before: updates }));
watcher.on('change', path => console.log({ changed: path }));
watcher.on('after', updates => console.log({ after: updates }));
watcher.on('delete', path => console.log({ deleted: path }));

Copyright & contributors

Copyright © 2023 Leadfisher contributors. Leadwatch is MIT licensed.
Leadwatch is one of leadfisher solutions.