Comparing version
{ | ||
"name": "sane", | ||
"version": "1.4.1", | ||
"version": "1.5.0", | ||
"description": "Sane aims to be fast, small, and reliable file system watcher.", | ||
@@ -16,3 +16,3 @@ "main": "index.js", | ||
"prepublish": "jshint --config=.jshintrc src/ index.js && mocha --bail", | ||
"test": "jshint --config=.jshintrc src/ index.js && mocha --bail", | ||
"test": "jshint --config=.jshintrc src/ index.js && mocha --bail test/test.js && mocha --bail test/utils-test.js", | ||
"test:debug": "mocha debug --bail" | ||
@@ -32,2 +32,3 @@ }, | ||
"dependencies": { | ||
"anymatch": "^1.3.0", | ||
"exec-sh": "^0.2.0", | ||
@@ -34,0 +35,0 @@ "fb-watchman": "^1.8.0", |
@@ -0,1 +1,3 @@ | ||
[](https://circleci.com/gh/amasad/sane) | ||
sane | ||
@@ -2,0 +4,0 @@ ---- |
'use strict'; | ||
var anymatch = require('anymatch'); | ||
var minimatch = require('minimatch'); | ||
@@ -31,2 +32,7 @@ | ||
} | ||
watcher.hasIgnore = Boolean(opts.ignored) && | ||
!(Array.isArray(opts) && opts.length > 0); | ||
watcher.doIgnore = opts.ignored ? anymatch(opts.ignored) : function () { | ||
return false; | ||
}; | ||
return opts; | ||
@@ -44,7 +50,8 @@ }; | ||
exports.isFileIncluded = function(globs, dot, relativePath) { | ||
exports.isFileIncluded = function(globs, dot, doIgnore, relativePath) { | ||
var matched; | ||
if (globs.length) { | ||
for (var i = 0; i < globs.length; i++) { | ||
if (minimatch(relativePath, globs[i], {dot: dot})) { | ||
if (minimatch(relativePath, globs[i], {dot: dot}) && | ||
!doIgnore(relativePath)) { | ||
matched = true; | ||
@@ -56,9 +63,6 @@ break; | ||
// Make sure we honor the dot option if even we're not using globs. | ||
if (!dot) { | ||
matched = minimatch(relativePath, '**/*', {dot: false}); | ||
} else { | ||
matched = true; | ||
} | ||
matched = (dot || minimatch(relativePath, '**/*')) && | ||
!doIgnore(relativePath); | ||
} | ||
return matched; | ||
}; |
@@ -75,3 +75,7 @@ 'use strict'; | ||
var relativePath = path.relative(this.root, filepath); | ||
if (!common.isFileIncluded(this.globs, this.dot, relativePath)) { | ||
if (!common.isFileIncluded( | ||
this.globs, | ||
this.dot, | ||
this.doIgnore, | ||
relativePath)) { | ||
return false; | ||
@@ -280,3 +284,7 @@ } | ||
this.watchdir(fullPath); | ||
if (common.isFileIncluded(this.globs, this.dot, relativePath)) { | ||
if (common.isFileIncluded( | ||
this.globs, | ||
this.dot, | ||
this.doIgnore, | ||
relativePath)) { | ||
this.emitEvent(ADD_EVENT, relativePath, stat); | ||
@@ -283,0 +291,0 @@ } |
@@ -63,2 +63,3 @@ 'use strict'; | ||
this.dot, | ||
this.doIgnore, | ||
path.relative(this.root, filepath) | ||
@@ -65,0 +66,0 @@ ); |
@@ -217,4 +217,8 @@ 'use strict'; | ||
if (!self.capabilities.wildmatch && | ||
!common.isFileIncluded(this.globs, this.dot, relativePath)) { | ||
if (!(self.capabilities.wildmatch && !this.hasIgnore) && | ||
!common.isFileIncluded( | ||
this.globs, | ||
this.dot, | ||
this.doIgnore, | ||
relativePath)) { | ||
return; | ||
@@ -221,0 +225,0 @@ } |
28135
2.16%839
2.07%128
1.59%7
16.67%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added