JSPM

  • Created
  • Published
  • Downloads 4135116
  • Score
    100M100P100Q230671F
  • License MIT

Sane aims to be fast, small, and reliable file system watcher. No bells and whistles, just change events.

Package Exports

  • sane

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sane) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

sane

I've been driven to insanity by node filesystem watcher wrappers. Sane aims to be fast, small, and reliable file system watcher.

Install

Requires node >= v0.10.0.

$ npm install sane

API

sane(dir, globs)

Watches a directory and all it's descendant directorys for changes, deletions, and additions on files and directories. Shortcut for new sane.Watcher(files, {globs: globs}).

var watcher = sane('path/to/dir', ['**/*.js, '**/*.css']);
watcher.on('ready', function () { console.log('ready') });
watcher.on('change', function (filepath) { console.log('file changed', filepath); });
watcher.on('add', function (filepath) { console.log('file added', filepath); });
watcher.on('delete', function (filepath) { console.log('file deleted', filepath); });
// close
watcer.close();

sane.Watcher(dir, options)

options:

  • persistent: boolean indicating that the process shouldn't die while we're watching files.
  • glob: a single string glob pattern or an array of them.

For the glob pattern documentation, see minimatch.

sane.Watcher#close

sane.Watcher events

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 directory
  • change when a file changes
  • add when a file or directory has been added
  • delete when a file or directory has been deleted

Stops watching.

License

MIT