Security News
NVD Backlog Tops 20,000 CVEs Awaiting Analysis as NIST Prepares System Updates
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Watchr provides a normalised API the file watching APIs of different node versions, nested/recursive file and directory watching, and accurate detailed events for file/directory changes, deletions and creations.
You install it via npm istall watchr
and use it via require('watchr').watch(config)
. Available configuration options are:
path
a single path to watchpaths
an array of paths to watchlistener
a single listener to fire when a change occurslisteners
an array of listeners to fire when a change occursnext
(optional, defaults to null
) a completion callback to fire once the watchers have been setupstat
(optional, defaults to null
) a file stat object to use for the path, instead of fetching a new oneignoreHiddenFiles
(optional, defaults to false
) whether or not to ignored files which filename starts with a .
ignoreCommonPatterns
(optional, defaults to true
) whether or not to ignore common undesirable file patterns (e.g. .svn
, .git
, .DS_Store
, thumbs.db
, etc)ignoreCustomPatterns
(optional, defaults to null
) any custom ignore patterns that you would also like to ignore along with the common patternsinterval
(optional, defaults to 100
) for systems that poll to detect file changes, how often should it poll in millsecondspersistent
(optional, defaults to true
) whether or not we should keep the node process alive for as long as files are still being watchedListeners will be triggered whenever a change is made on the directory or for anything inside it (including sub-directories and so on) and are in the following format var listener = function(eventName,filePath,fileCurrentStat,filePreviousStat){}
There are three types of events for your listeners at your disposal:
change
: a file has been modifiednew
: a new file or directory has been createdunlink
: a file or a directory has been removedTo wrap it all together, it would look like this:
// Require
watchr = require('watchr')
// Watch a directory or file
watchr.watch({
path: path,
listener: function(eventName,filePath,fileCurrentStat,filePreviousStat){
console.log('a watch event occured:',arguments);
},
next: function(err,watcher){
if (err) throw err;
console.log('watching setup successfully');
}
});
You can test the above code snippet by installing watchr globally by running npm install -g watchr
to install watchr, then watchr <pathToWatch>
to watchr a particular path, and performing some file system modifications on that path.
Thanks for using Watchr!
Support can be found in the GitHub Issue Tracker
You can discover the history inside the History.md file
Licensed under the incredibly permissive MIT License
Copyright © 2012 Bevry Pty Ltd
Copyright © 2011 Benjamin Lupton
v2.2.1 2012 December 16
FAQs
Better file system watching for Node.js
The npm package watchr receives a total of 21,034 weekly downloads. As such, watchr popularity was classified as popular.
We found that watchr demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.