gaze

gaze (GitHub: shama/gaze, License: MIT) a globbing fs.watch wrapper written byKyle Robinson Youngand built from the best parts of other fine watch libs. Compatible with Node.js0.10/0.8, Windows, OSX and Linux. There’s apretty long list of other great modulesthat are built on top of gaze.

1
npm install gaze

Usage

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
var gaze = require('gaze');
// Watch all .js files/dirs in process.cwd()
gaze('**/*.js'function(err, watcher) {
  // Files have all started watching
  // watcher === this
  // Get all watched files
  console.log(this.watched());
  // On file changed
  this.on('changed'function(filepath) {
    console.log(filepath + ' was changed');
  });
  // On file added
  this.on('added'function(filepath) {
    console.log(filepath + ' was added');
  });
  // On file deleted
  this.on('deleted'function(filepath) {
    console.log(filepath + ' was deleted');
  });
  // On changed/added/deleted
  this.on('all'function(event, filepath) {
    console.log(filepath + ' was ' + event);
  });
  // Get watched files with relative paths
  console.log(this.relative());
});
// Also accepts an array of patterns
gaze(['stylesheets/*.css''images/**/*.png'], function() {
  // Add more patterns later to be watched
  this.add(['js/*.js']);
});

I’ve been getting my feet wet with gulp.js and specificallygulp-watch (GitHub: floatdrop/gulp-watch, License: MIT)plugin which helps you process only the files that were changed. This helps tospeed up asset building quite a bit.Are you using any file watchers in your project?

Post navigation

Leave a comment

Leave a Reply

Your email address will not be published.