website/node_modules/gaze/README.md

gaze Build Status Build status

A globbing fs.watch wrapper built from the best parts of other fine watch libs. Compatible with Node.js >= 4.x, Windows, macOS, and Linux.

gaze

NPM

Usage

Install the module with: npm install gaze or place into your package.json and run npm install.

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
  var watched = 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
  var files = 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']);
});

Alternate Interface

var Gaze = require('gaze').Gaze;

var gaze = new Gaze('**/*');

// Files have all started watching
gaze.on('ready', function(watcher) { });

// A file has been added/changed/deleted has occurred
gaze.on('all', function(event, filepath) { });

Errors

gaze('**/*', function(error, watcher) {
  if (error) {
    // Handle error if it occurred while starting up
  }
});

// Or with the alternative interface
var gaze = new Gaze();
gaze.on('error', function(error) {
  // Handle error here
});
gaze.add('**/*');

Minimatch / Glob

See isaacs's minimatch for more information on glob patterns.

Documentation

gaze([patterns, options, callback])

Class: gaze.Gaze

Create a Gaze object by instancing the gaze.Gaze class.

var Gaze = require('gaze').Gaze;
var gaze = new Gaze(pattern, options, callback);

Properties

Events

Methods

Similar Projects

Other great watch libraries to try are:

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.

Release History

License

Copyright (c) 2018 Kyle Robinson Young Licensed under the MIT license.



JohnCoene/chirp documentation built on May 25, 2021, 6:33 p.m.