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



Thin wrapper for with glob-pattern matching.


var watcher = new Ogle(['lib/some-dir/', 'lib/some-dir/*.js']);
watcher.on('add', function(dir, newFile) {
  console.log("File %s added to directory %s", newFile, dir);
watcher.on('change', function(filePath) {
  console.log("File %s changed", filePath);
watcher.on('remove', function(filePath) {
  console.log("File %s was deleted", filePath);
watcher.on('all', function(event, filePath, otherPath) {
  switch(event) {
    case 'add':
      console.log("File %s added to directory %s", filePath, otherPath);
    case 'change':
      console.log("File %s changed", filePath);
    case 'remove':
      console.log("File %s deleted", filePath);


There are already many wrappers on Unfortunately, non of them seemed to be usable without making sacrifices. Ogle chooses the following advantages:

  • glob pattern matching
  • all/remove/change events on files
  • all/add/remove/change events on directories
  • Auto-adding of listeners for new files in directories (if we are watching the directory)
  • Use of instead of fs.watchFile. See here for why.

Complete documentation

Coming soon...