node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »


este-watch Build Status Dependency Status

Fast and reliable Node.js files watcher.

  • It's fast, because it wraps which does not use pooling.
  • It's reliable, because it supports only that behavior that works reliable across all OS's.

Why yet another file watcher?

There are zilions Node.js file watchers. No one is perfect. The most feature rich is probably gaze, but it burns CPU because it uses pooling fs.watchFile. This watcher uses only so it has limited functionality (can't detect deleted files), but it works. And it's fast even for thousands of files. Read more here and here.

Basic Usage

Create a watcher to watch all files in the directories "foo" and "bar":

function onWatch(file) {
  // Relative path to file that was changed or created 
  // File Extension 
var esteWatch = require('este-watch');
var watcher = esteWatch(['foo', 'bar'], onWatch);
// Start the watcher 


A third argument can be passed to the esteWatch function to specify options.

Three options are available:

  • filter: (RegExp) only fire watcher callback for files where the full relative filepath matches this pattern
  • ignoreFiles: (RegExp) prevent watcher callback from firing for files where the full relative filepath matches this pattern
  • ignoreDirectories: (RegExp) prevent watcher from even starting for directories where the full relative directory path matches this pattern
esteWatch(['foo', 'bar'], onWatch, {
  filter: /\.js$/,
  ignoreFiles: /\.min\.js$/,
  ignoreDirectories: /node_modules/,