@ajukno/mite
v1.0.1
Published
A simple tool to watch file changes
Downloads
4
Readme
Features
- Watches for file changes in specified paths
- Supports multiple event types including 'add', 'addDir', 'change', 'unlink', 'unlinkDir', and 'all'
- Provides an easy-to-use API to initialize the watcher and add event listeners
Usage
First, import Mite into your project:
import { mite } from '@ajukno/mite';
Then, initialize Mite with the paths you want to watch:
mite.init({ paths: '.' });
You can add event listeners using the on
method:
mite.on(['add'], (path) => {
console.log(`File added: ${path}`);
});
To stop the watcher, use the stop
method:
await mite.stop();
API
init(options: MiteOptions): void
Initializes Mite with the given options. The options
object should have the following properties:
paths
: A string or an array of strings specifying the paths to watchoptions
(optional): An object specifying the watch options
on(events: MiteEventName[], callback: (path: string) => Promise<void> | void): void
Adds an event listener. The events
parameter is an array of event names to listen for. The callback
is a function
that is called when any of the specified events occur.
stop(): Promise<void>
Stops the file watcher.
Tests
Mite has a suite of tests that can be run using Vitest. To run the tests, use the following command:
npm run test
License
Mite is licensed under the MIT license.