How to use the chokidar.FSWatcher.prototype function in chokidar

To help you get started, we’ve selected a few chokidar examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github laggingreflex / mochista / watcher / init.js View on Github external
const assert = require('assert');
const { FSWatcher, watch } = require('chokidar');
const debounce = require('debounce-queue');
const normalize = require('normalize-path');
const anymatch = require('anymatch');
const log = require('../utils/logger');

// temporary patch for chokidar#561
const org_addToNodeFs = FSWatcher.prototype._addToNodeFs;
FSWatcher.prototype._addToNodeFs = function patched_addToNodeFs (path, initialAdd, priorWh, depth, target, callback) {
  org_addToNodeFs.call(this, path, initialAdd, null, depth, target, callback);
};

module.exports = function init ({
  root,
  include,
  exclude = [],
  onChange
}) {
  assert(root, 'Need a root');
  assert(include && include.length, 'Need files to watch {include}');

  log('Readying watcher...');
  log.verbose(`Include ${include.length} files`);
  include.forEach(f => log.silly('', f));
  if (exclude.length) {
github laggingreflex / mochista / watcher / init.js View on Github external
const assert = require('assert');
const { FSWatcher, watch } = require('chokidar');
const debounce = require('debounce-queue');
const normalize = require('normalize-path');
const anymatch = require('anymatch');
const log = require('../utils/logger');

// temporary patch for chokidar#561
const org_addToNodeFs = FSWatcher.prototype._addToNodeFs;
FSWatcher.prototype._addToNodeFs = function patched_addToNodeFs (path, initialAdd, priorWh, depth, target, callback) {
  org_addToNodeFs.call(this, path, initialAdd, null, depth, target, callback);
};

module.exports = function init ({
  root,
  include,
  exclude = [],
  onChange
}) {
  assert(root, 'Need a root');
  assert(include && include.length, 'Need files to watch {include}');

  log('Readying watcher...');
  log.verbose(`Include ${include.length} files`);
  include.forEach(f => log.silly('', f));

chokidar

Minimal and efficient cross-platform file watching library

MIT
Latest version published 3 days ago

Package Health Score

91 / 100
Full package analysis