0.1.1 • Published 8 months ago

@hitomihiumi/filewatcher v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

FileWatcher

npm version downloads

Overview

FileWatcher is a Node.js utility that monitors file system changes in specified directories. It can detect file additions, modifications, and deletions, and allows you to set custom handlers for these events.

Features

  • Monitor multiple directories
  • Set custom handlers for file events (add, change, unlink)
  • Ignore specific directories
  • Filter by allowed file extensions

Installation

npm install @hitomihiumi/filewatcher

Usage

const FileWatcher = require('@hitomihiumi/filewatcher');

const watcher = new FileWatcher()
    .setAllowedExtensions('.js');

watcher.setHandler('./test', 'change', (dir, file, relativePath) => {
    console.log(`File ${file} changed at ${relativePath}`);
})
.setHandler('./test', 'add', (dir, file, relativePath) => {
    console.log(`File ${file} added at ${relativePath}`);
})
.setHandler('./test', 'unlink', (dir, file, relativePath) => {
    console.log(`File ${file} removed at ${relativePath}`);
});

watcher.setMonitoredDirectories('./test');

watcher.startWatching();

FileWatcher

0.1.1

8 months ago

0.1.0

8 months ago