![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
node-watch
Advanced tools
Readme
#Node-watchj A fs.watch wrapper to watch files or directories(recursively by default).
npm install node-watch
var watch = require('node-watch');
watch('somedir_or_somefile', function(filename) {
console.log(filename, ' changed.');
});
This module currently does not differentiate event like rename
or delete
. Once there is a change, the callback function will be triggered.
recursive
:Watch it recursively or not (defaults to true).
followSymLinks
: Follow symbolic links or not (defaults to false).
maxSymLevel
: The max number of following symbolic links, in order to prevent circular links (defaults to 1).
filter
: node-watch will only watch elements that pass the test implemented by the provided function. The filter function is provided with a full path string argument(defaults to (fullPath)=>true
).
watch('somedir', { recursive: false, followSymLinks: true }, function(filename) {
console.log(filename, ' changed.');
});
Since v0.4.0 watch()
will return a [fs.FSWatcher](fs.FSWatcher like object,
so you can close the watcher or detect change by change
event instead of the old callback function.
var watcher = watch('./');
watcher.on('change', function(file) {
//
});
watcher.on('error', function(err) {
});
// close
watcher.close();
###FAQ
watch(['file1', 'file2'], function(file) {
//
});
You can write your own filter function as a higher-order function. For example:
var filter = function(pattern, fn) {
return function(filename) {
if (pattern.test(filename)) {
fn(filename);
}
}
}
// only watch for js files
watch('mydir', filter(/\.js$/, function(filename) {
//
}));
Alternatively, supply a filter function in the options object. For example:
// don't watch node_modules folder
var options = {
filter : function(filename) {
return !/node_modules/.test(filename);
}
};
watch('mydir', options, function(filename) {
//
}));
The second approach helps avoiding the max open files limit
FAQs
A wrapper and enhancements for fs.watch
The npm package node-watch receives a total of 383,936 weekly downloads. As such, node-watch popularity was classified as popular.
We found that node-watch demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.