Gathering detailed insights and metrics for sane
Gathering detailed insights and metrics for sane
Gathering detailed insights and metrics for sane
Gathering detailed insights and metrics for sane
sane aims to be fast, small, and reliable filesystem watcher. No bells and whistles, just change events.
npm install sane
Use watchmans's watch-project by default
Published on 01 May 2015
'all' event
Published on 02 Sept 2014
Include root directory in event callbacks
Published on 17 Aug 2014
`sane()` takes options
Published on 14 Jul 2014
normalize paths
Published on 02 Jul 2014
Fix deleting directories on windows
Published on 18 Jun 2014
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
387 Stars
208 Commits
66 Forks
15 Watching
14 Branches
35 Contributors
Updated on 13 Oct 2024
Minified
Minified + Gzipped
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-5%
1,558,356
Compared to previous day
Last week
6.9%
9,170,940
Compared to previous week
Last month
64.8%
30,911,832
Compared to previous month
Last year
-31.6%
275,234,537
Compared to previous year
I've been driven to insanity by node filesystem watcher wrappers. Sane aims to be fast, small, and reliable file system watcher. It does that by:
fs.watch
by default and sensibly works around the various issuesfs.watch
is not reliable you have the choice of using the following alternatives:
$ npm install sane
Don't worry too much about choosing the correct mode upfront because sane maintains the same API across all modes and will be easy to switch.
watchman
would be the most reliable modewatchman
Watches a directory and all its descendant directories for changes, deletions, and additions on files and directories.
1var watcher = sane('path/to/dir', {glob: ['**/*.js', '**/*.css']}); 2watcher.on('ready', function () { console.log('ready') }); 3watcher.on('change', function (filepath, root, stat) { console.log('file changed', filepath); }); 4watcher.on('add', function (filepath, root, stat) { console.log('file added', filepath); }); 5watcher.on('delete', function (filepath, root) { console.log('file deleted', filepath); }); 6// close 7watcher.close();
options:
glob
: a single string glob pattern or an array of them.poll
: puts the watcher in polling mode. Under the hood that means fs.watchFile
.watchman
: makes the watcher use watchman.watchmanPath
: sets a custom path for watchman
binary.watchexec
: makes the watcher use watchexec.dot
: enables watching files/directories that start with a dot.ignored
: a glob, regex, function, or array of any combination.For the glob pattern documentation, see micromatch.
If you choose to use watchman
you'll have to install watchman yourself).
If you choose to use watchexec
you'll have to install watchexec yourself).
For the ignored options, see anymatch.
The default watcher class. Uses fs.watch
under the hood, and takes the same options as sane(dir, options)
.
The watchman watcher class. Takes the same options as sane(dir, options)
.
The watchexec watcher class. Takes the same options as sane(dir, options)
.
The polling watcher class. Takes the same options as sane(dir, options)
with the addition of:
Stops watching.
Emits the following events:
All events are passed the file/dir path relative to the root directory
ready
when the program is ready to detect events in the directorychange
when a file changesadd
when a file or directory has been addeddelete
when a file or directory has been deletedThis module includes a simple command line interface, which you can install with npm install sane -g
.
Usage: sane <command> [...directory] [--glob=<filePattern>] [--poll] [--watchman] [--watchman-path=<watchmanBinaryPath>] [--dot] [--wait=<seconds>]
OPTIONS:
--glob=<filePattern>
A single string glob pattern or an array of them.
--ignored=<filePattern>
A glob, regex, function, or array of any combination.
--poll, -p
Use polling mode.
--watchman, -w
Use watchman (if available).
--watchman-path=<watchmanBinaryPath>
Sets a custom path for watchman binary (if using this mode).
--dot, -d
Enables watching files/directories that start with a dot.
--wait=<seconds>
Duration, in seconds, that watching will be disabled
after running <command>. Setting this option will
throttle calls to <command> for the specified duration.
--quiet, -q
Disables sane's console output
--changes-only, -o
Runs <command> only when a change occur. Skips running <command> at startup
It will watch the given directory
and run the given
sane 'echo "A command ran"'
sane 'echo "A command ran"' --glob='**/*.css'
sane 'echo "A command ran"' site/assets/css --glob='**/*.css'
sane 'echo "A command ran"' --glob='**/*.css' --ignored='**/ignore.css'
sane 'echo "A command ran"' --wait=3
sane 'echo "A command ran"' -p
MIT
The CLI was originally based on the watch CLI. Watch is licensed under the Apache License Version 2.0.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
Found 9/27 approved changesets -- score normalized to 3
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
license file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
16 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More