Closed codeviking closed 9 years ago
I think this does it:
diff --git a/index.js b/index.js
index 6fb2398a..40647865 100644
--- a/index.js
+++ b/index.js
@@ -1,8 +1,8 @@
var through = require('through2');
var path = require('path');
+var anymatch = require('anymatch');
var chokidar = require('chokidar');
var xtend = require('xtend');
-var anymatch = require('anymatch');
module.exports = watchify;
module.exports.args = {
@@ -19,7 +19,7 @@ function watchify (b, opts) {
var wopts = {persistent: true};
if (opts.ignoreWatch) {
- wopts.ignored = opts.ignoreWatch !== true
+ var ignored = opts.ignoreWatch !== true
? opts.ignoreWatch
: '**/node_modules/**';
}
@@ -96,10 +96,11 @@ function watchify (b, opts) {
function watchFile (file, dep) {
dep = dep || file;
- // don't watch files which are explicitly ignored
- if (wopts.ignored && (ignoredFiles[file] || anymatch([wopts.ignored], dep))) {
- ignoredFiles[file] = true;
- return;
+ if (ignored) {
+ if (!ignoredFiles.hasOwnProperty(file)) {
+ ignoredFiles[file] = anymatch(ignored, file);
+ }
+ if (ignoredFiles[file]) return;
}
if (!fwatchers[file]) fwatchers[file] = [];
if (!fwatcherFiles[file]) fwatcherFiles[file] = [];
Great points, thanks for the patch. I'll update and test locally.
No worries on timing!
@zertosh Updated PR with the fix such that a watcher isn't attached to files which are explicitly ignored.