Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
fs-watch-tree
Advanced tools
Please note! This package is outdated and not actively maintained. I would suggest looking at http://github.com/shama/gaze or https://github.com/paulmillr/chokidar.
fs-watch-tree is a small tool to watch directories for changes recursively. It uses fs-watch to watch for changes, thus should work on most platforms.
var watchTree = require("fs-watch-tree").watchTree;
var watch = watchTree("/home/christian", function (event) {
// See description of event below
});
watch.end(); // Release watch
watch = watchTree("/home/christian", {
exclude: ["node_modules", "~", "#", /^\./]
}, function (event) {
// Respond to change
});
watchTree(dir, callback)
Watches directory dir
recursively for changes.
The callback is called with an event
object. The event is described below.
watchTree(dir, options, callback)
Watch a directory recursively, with some specific options. Currently, you can only specify a single option:
{ exclude: [] }
The exclude
array specifies file patterns to exclude from watches. If a
pattern matches a directory, watch-tree
will not recurse into it. If it
matches a file, changes to that file will not trigger an event.
The excludes can be either strings or regular expressions, but are always treated as regular expressions. That means that
{ exclude: [".git", "node_modules"] }
Will be treated the same way as:
{ exclude: [new RegExp(".git"), new RegExp("node_modules")] }
If you only want to exclude specific files, be sure to provide full
paths. watch-tree
does not expand paths, it will resolve all paths relative to
the original directory. So this:
watchFile(".git", function (event) { /* ... *) });
Will watch (and consider excludes for) directories like .git/branches
. And
this:
watchFile("/home/christian/projects/watch-tree/.git", function (event) {});
Will watch (and consider excludes for) directories like
/home/christian/projects/watch-tree/.git
.
event
The event object has the following properties:
name
The full (relative) path to the file/directory that changed.
isDirectory()
Returns true if the cause of the change was a directory. In some cases, e.g. when the directory was deleted, it's not possible to know if the source was a directory. In that case, this method returns false.
isMkdir()
Returns true if the cause of the event was a newly created directory.
isDelete()
Returns true if the cause of the event was a deleted file/directory.
isModify()
Returns true if the cause of the event was a modified file/directory.
FAQs
Recursively watch directories for changes
We found that fs-watch-tree demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.