
Security News
PodRocket Podcast: Inside the Recent npm Supply Chain Attacks
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
@nasriya/overwatch
Advanced tools
A high-performance, dependency-free file system watcher that monitors file and directory changes efficiently across platforms.
Made with ❤️ in Palestine 🇵🇸
Overwatch is a fast, reliable, and efficient file system watcher built with TypeScript. It supports flexible filtering using globs and regexes, making it ideal for scalable, cross-platform file monitoring with minimal resource usage.
[!IMPORTANT]
🌟 Support Our Open-Source Development! 🌟 We need your support to keep our projects going! If you find our work valuable, please consider contributing. Your support helps us continue to develop and maintain these tools.
Every contribution, big or small, makes a difference. Thank you for your generosity and support!
npm i @nasriya/overwatch
Import in ES6 module
import overwatch from '@nasriya/overwatch';
Import in CommonJS (CJS)
const overwatch = require('@nasriya/overwatch').default;
Use overwatch.watchFolder()
(recommended) or overwatch.watch()
to watch a directory. You can optionally provide filters to include or exclude specific paths:
// Strongly recommended: use `watchFolder` for directories
const projectWatcher = await overwatch.watchFolder(process.cwd(), {
include: ['**/*.ts'], // Accepts globs, regex, or absolute paths
exclude: [/node_modules/, '**/*.test.ts'],
});
Or without watching options:
const projectWatcher = await overwatch.watchFolder(process.cwd());
You can also watch indivisual files:
const fileWatcher = await overwatch.watchFile('src/config.json');
You can attach a general handler for all change events:
// Handles all the watcher's events
projectWatcher.onChange(({ type, event }) => {
// Handle different event types
switch (type) {
case 'add':
console.log(`Added ${event.type}: ${event.path}`);
break;
case 'remove':
console.log(`Removed ${event.type}: ${event.path}`);
break;
case 'rename':
console.log(`Renamed ${event.type}: ${event.oldPath} -> ${event.newPath}`);
break;
case 'update':
console.log(`Updated ${event.type}: ${event.path}`);
break;
case 'rootRemoved':
console.log(`Watcher root was deleted`);
break;
}
// NOTE: `event.type` is the type of the changed item, either `File` or `Folder`
});
Or, register dedicated handlers for specific events:
projectWatcher.onAdd((path) => {
console.log(`Added: ${path}`);
});
projectWatcher.onRemove((event) => {
console.log(`${event.type} removed: ${event.path}`);
});
projectWatcher.onRename((event) => {
console.log(`${event.type} renamed: ${event.oldPath} -> ${event.newPath}`);
});
projectWatcher.onUpdate((event) => {
console.log(`${event.type} updated: ${event.path}`);
});
You can also pass the handlers when you create the watcher:
const projectWatcher = await overwatch.watchFolder(process.cwd(), {
include: ['**/*.ts'], // Accepts globs, regex, or absolute paths
exclude: [/node_modules/, '**/*.test.ts'],
onRename: (event) => {
console.log(`${event.type} renamed: ${event.oldPath} -> ${event.newPath}`);
}
});
If the root directory being watched is deleted, a special event is triggered:
projectWatcher.onRootRemoved(() => {
console.log('The watched directory was deleted.');
});
include
and exclude
accept absolute paths, glob patterns (e.g., '**/*.ts'
), and regular expressions (e.g., /\.test\.ts$/
).watchFolder()
and watchFile()
over the general watch()
method for clearer intent and improved readability.include
, exclude
) do not impact scanning performance; they only determine which changes are emitted to the user.event.type
refers to the type of the changed item — either 'File'
or 'Folder'
.onChange
) will replace the previous one.rootRemoved
event is emitted.overwatch.control.pause()
and overwatch.control.resume()
to temporarily stop and restart the internal scanning engine without removing watchers.This software is licensed under the Nasriya Open License (NOL), version 1.0. Please read the license from here.
FAQs
A high-performance, dependency-free file system watcher that monitors file and directory changes efficiently across platforms.
We found that @nasriya/overwatch demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.