Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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) {
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));