sane
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
@cnakazawa/watch | 1.0.4 | 8.34 kB | Apache-2.0 | prod | |
anymatch | 3.1.3 | 3.57 kB | ISC | prod | |
capture-exit | 2.0.0 | 2.36 kB | ISC | prod | |
exec-sh | 0.3.6 | 7.77 kB | MIT | prod | |
execa | 4.1.0 | 14.02 kB | MIT | prod | |
fb-watchman | 2.0.2 | 4.02 kB | Apache-2.0 | prod | |
micromatch | 4.0.7 | 54.95 kB | MIT | prod | |
minimist | 1.2.8 | 15.16 kB | MIT | prod | |
walker | 1.0.8 | 2.17 kB | Apache-2.0 | prod |
Sane is a fast, lightweight, and reliable file system watcher, designed to handle commonly faced issues with Node filesystem watcher wrappers. It provides a dependable solution to monitoring directories and their descendant directories for file and folder changes, deletions, and additions. The tool avoids filesystem polling by default since it can be CPU intensive and slow, opting instead to use fs.watch
, but it provides alternative options where fs.watch
is not reliable, such as the Facebook Watchman library and the Watchexec library.
Utilizing Sane requires installation via npm using the command $ npm install sane
. Once installed, you can instantiate a watcher for a particular directory by invoking the sane
function and passing in the directory path, along with a set of options. Here's an example usage:
var watcher = sane('path/to/dir', {glob: ['**/*.js', '**/*.css']});
watcher.on('ready', function () { console.log('ready') });
watcher.on('change', function (filepath, root, stat) { console.log('file changed', filepath); });
watcher.on('add', function (filepath, root, stat) { console.log('file added', filepath); });
watcher.on('delete', function (filepath, root) { console.log('file deleted', filepath); });
// to stop watching
watcher.close();
This code sets up a file watcher on the specified directory, filtering for changes to JavaScript and CSS files. The watcher outputs console logs when files are added, changed, or deleted.
The detailed documentation for Sane can be found in the package's README, available on the Sane GitHub repository (git+https://github.com/amasad/sane.git). The documentation includes a comprehensive API guide, a set of instructions on how to select a mode, details on how to install the package, usage examples, options available for configuration, and customization possibilities. Information is also included about the Command Line Interface (CLI), discussing appropriate installation methods and example usage.