Watch specific files, directories, deeply nested directories
Rebuild recursive when new directories found or old directories remove
Deduplicate events with debounce
npm i leadwatch --save
const DirectoryWatcher = require('astrowatch');
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
home: process.cwd(), // Removes root path from emits, Warning: ignore will work on full paths
});
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('delete', path => console.log({ deleted: path }));
watcher.on('after', updates => console.log({ after: updates }));
Copyright © 2023 Astrohelm contributors.
Astrowatch is MIT licensed.
Astrowatch is part of Astrohelm ecosystem.